Flask is a web application (WSGI) framework. It is intended to start quickly and easily, with the ability to develop complex apps. It started as a simple wrapper around tools and jinja became one of Python’s most popular web application template languages.

But Flask does not implement any dependencies or project layout. It is the developer ‘s responsibility to select the tools and libraries to be used. The community offers many extensions that make it easy to add new functionality.

Related course: Python Flask: Create Web Apps with Flask

Python Flask Framework

Flask is a framework for the web. What means is that flask lets you develop a web application. This can be a web site, a blog, a webapp.

For creating APIs and backend of webapp, Flask is very awesome. Firstly, Python and Pip must be installed on your device. You can check the official website if you do not have it installed.

Flask is micro framework. This does not imply that the whole Web app has to fit in a single Python file or that Python Flask does not have any functionality.

Flask sets up the core basics of your app. Flask does not take other choices, including the design to use for your app. Decisions such as what to use the template engine are easy to change.

python flask web framework

Flask app

Install and update using pip:

pip install -U Flask

You can create a new folder to develop your app, after you’ve installed the Flask framework. Create a file called hello.py in this folder.

Import dependencies to construct a Flask app

from flask import Flask

app = Flask(__name__)

Then create a route and function that returns the output.

We will begin, after all, to define the routes of our application. We describe routes using the @app.route() decorator. In this example the route is the GET method that we supply as a ‘/‘ (root). This will call the function hello() and return Hello, World!

A Simple Example

from flask import Flask

app = Flask(__name__)

@app.route("/")
def hello():
return "Hello, World!"

flask hello world app

Start the app

$ env FLASK_APP=hello.py flask run
* Serving Flask app "hello"
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

Related course: Python Flask: Create Web Apps with Flask