Flask is the Python framework for building web application. It’s so pupular because of the simplicity. So simple that it doesn’t ship with batteris like ORM. But it has huge collection of third-party libraries. You can use that to create web application without righting lot of codes. Enough of the build up let’s see how easy to create web application in Flask.
from flask import Flask
app = Flask(__name__)
@app.route("/")
def index():
return "Hello World"
This is how you write hello wolrd application in Flask. Look at the code it’s so mininal. Not more than 5 lines. You can run this code with wsgi server like gunicorn but flask also ship with CLI tool. To run using flask cli you need to export your app instance like this.
export FLASK_APP=helloworld.py
That’s it now you can issue this command flask run and it will start the development server. And then you can browse localhost ip address in browser.