What is Flask ?

Flask is Python Web Framework . Unlike Django it is considered as Micro -Framework as it does not require set of tools or libraries.

Flask Vs Django

One Biggest Problems for Machine Learning Engineers ,AI Engineers and Data Scientists is deploy their model . Often deploying model is huge task for Python Developers . Then Enters Flask , Streamlit & Django . Streamlit is for Small applications and Data Visualizations and still upcoming state . SO , Lets take a look at Flask & Django

Stack Overflow Questions Flask vs. Django

Installing Flask

First Install Pip

$ python -m pip --version
pip install -U Flask

Now Let’s Check a Simple Flask App

Where everyone will start . Yes, it is Hello World Program !!

from flask import Flask
app = Flask(__name__)

def hello_world():
return 'Hello World'

if __name__ == '__main__':
  1. First we imported the Flask
  2. Create app, that hosts the application
  3. Then you need a route that calls a Python function. A route maps what you type in the browser (the url) to a Python function
  4. The function should return something to the web browser,
  5. (app.run()) This is Python for “if this script is run directly then start the application”.

Command Line

$ env FLASK_APP=hello.py flask run
* Serving Flask app "hello"
* Running on (Press CTRL+C to quit)
Hey !! That’s it You have executed your first Flask Program



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store