Create Python web app using Flask Framework

We will be leaning how to create a Python web app using Flask in series of articles, Now in this post I will show you how to set up Flask frame work for web development using python and run a simple code to check the set up.

  1. Why do we choose python over other tech stacks?
    • Python is simple and lightweight. You can focus on your design and logic’s rather than the code complexity.
    • It is open-source and User friendly data structure and
    • Compatible with all the operating systems.
  2. Why do we choose the Flask Framework for web development?
    • Flask is a micro web development framework where it uses RESTful request dispatching.
    • It also has its own development server and debugging tool well-integrated for unit testing.
Python web app using Flask

Let’s jump into development. Here the shell scripts are used for mac-os. It might differ for windows.

python –version

    • Choose your IDE. Here we are choosing VS Code
    • Install pip with the below command. It is a utility to manage PyPI package installations from the command line

sudo easy_install pip

    • Install flask library using the below command

pip install flask

  • Let’s create a folder with the project name. Say flask_app

mkdir flask_app – Creates a folder

cd flask_app – Bash into the folder

  • Create a python file. Say

cat > – Creates new file in editable mode

  • Paste the below code snippet,
# import flask
from flask import Flask

# create an app instance
app = Flask(__name__)

# at the end point /
def hello():
    # which returns "hello world"
    return "Hello World!"
# on running python
if __name__ == "__main__":
    # run the flask app
  • Run the application with the below command. Flask runs on local server 5000 as default


Now our Python web app using flask is up and running! You will see the below command once the server is running

* Running on (Press CTRL+C to quit)

Once you click on you will see the return response from your flask app. Hello World!

Python web app using Flask

Read More – How to Speed up your WordPress website?

Leave a Comment