Python Flask Module
Flask module provides the basic and advanced concepts of the
Python Flask framework. Our Flask module is designed for
beginners and professionals.
Flask is a web framework that provides libraries to build lightweight
web applications in python.
What is Flask?
Flask is a web framework that provides libraries to build lightweight
web applications in python. Flask is considered as a web
framework.
Prerequisite
Before learning Flask, you must have the basic knowledge of Python concepts, HTML/CSS
If you are not familiar with Python check https://www.w3schools.com/Python/default.asp
And HTML https://www.w3schools.com/html/default.asp
CSS https://www.w3schools.com/css/default.asp
First Flask application
In this section of the tutorial, we will build our first python website built using the Flask framework.
In this process, open any text editor of your choice as we are using the sublime text editor in this
tutorial.
Write the following lines of code and save to a file named as app.py.
from flask import Flask
app = Flask(__name__)
@app.route('/home') # decorator defines a route
def home(): # each route has a function … recall def
return 'Our first Flask website'
if __name__ == '__main__':
app.run(debug=True)
Run the application, you get below on the python console,
* Serving Flask app "app" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: on
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 959-517-385
Open your browser and access this link http://127.0.0.1:5000/home
There you go with your first flask application.