What is Flask?

Flask is a micro-framework of python which is used in web development and has an easy to use syntax and makes use of jinja2 as the templating engine.

Flask makes backend web development a piece of cake for new learners because of the following reasons:-

· Python is much easier than JavaScript or PHP

· Most Universities teach python so we don’t need to learn a new language

· It takes minimal time to learn for a person having basic knowledge of python

· Compatible with SQL and NoSQL databases

Let’s get into the installation steps and learn some basic syntax

Installation Steps

Pre-requisites:-Python must be installed in your computer

If python is installed we can install flask using pip which is python’s package manager

Just open the terminal and type the following command

pip install -U Flask

Once flask is installed you are ready to get started

How to learn Flask?

There are numerous web sources through which flask could be learnt . If one has previous backend knowledge the Flask Documentation is the best place to learn it

Otherwise one can refer the following course on YouTube:-

· Python Flask by Traversy media

· Flask Tutorials by Corey Schafer

These two are one of the best free sources to learn Flask and get yourself underway in backend web development

Why Flask May Be Better Than Django

If your motive is to learn a backend framework quickly flask is the way to go.It helps us to get a feel of what backend programming is like.If the main focus of the programmer is experience flask is the better option.

However if you are more focused upon your end product and have enough backend experience Django might be better for you as it will help to reduce your efforts.

In short Flask is more simple and flexible but Django provides a better control to the programmer

Basic Syntax

from flask import Flask #The first line basically imports flask
app = Flask(__name__)  # __name__ is set to the current class function, method ,descriptor, or generator instance
@app.route('/') # a basic route, it will print hello word when run on localhost:portnumber/
def hello():
return 'Hello, World!'

Note:- Explanation for each line is in the comments above

On running the Server through Command line we will see:-

$ flask run
* Serving Flask app "hello"
* Running on (Press CTRL+C to quit)


Here are a few links one may refer to get going in Flask

Flask documentation:-

Flask Tutorials by Corey Schafer . :-

Flask Tutorials by Traversy media:-