1 Introduction to Flask
Mr. Shekhar D Jalane
Web Technology-I
Web Framework
2
Web Application Framework or simply
Web Framework represents a collection :
libraries and modules
Create Web Application
Without having to bother about low-level
details such as protocols, thread
management
Web Technology-I
What is Flask?
3
Flask is a web application framework
written in Python
It is developed by Armin Ronacher,
who leads an international group of
Python enthusiasts named Pocco
Flask is based on the Werkzeug WSGI
toolkit and Jinja2 template engine
Both are Pocco projects.
Web Technology-I
Flask as Web Application
4
Web Technology-I
Flask as ML Application
5
Web Technology-I
What is WSGI?
6
Web Server Gateway Interface (WSGI)
universal interface between the web
server and the web applications
Web Technology-I
What is Werkzeug ?
7
It is a Web Server Gateway Interface
toolkit
implements requests, response objects,
and other utility functions
The Flask framework uses Werkzeug as
one of its bases as Werkzeug Server
Web Technology-I
Flask as Web Application
8
Web Technology-I
What is Jinja2 ?
9
Jinja2 is a popular templating engine for
Python
A web templating system combines a
template with a certain data source to
render dynamic web pages
Web Technology-I
What is Jinja2 ?
10
Jinja2 is a popular templating engine for
Python
A web templating system combines a
template with a certain data source to
render dynamic web pages
Flask is often referred to as a micro
framework
Flask does not have built-in abstraction
layer
for database handling
Web Technology-I
Validation Support
Steps to Install Flask
11
Install Python
Web Technology-I
Steps to Install Flask
12
from flask import Flask
app = Flask(__name__)
@[Link]('/’)
def hello_world():
return 'Hello World’
if __name__ == '__main__’:
[Link]()
Web Technology-I
Flask Terminology
13
Importing flask module in the project is
mandator
An object of Flask class is
our WSGI application
Flask constructor takes the name
of current module (__name__) as
argument
The route() function of the Flask class is
a decorator
application which URL should call
Web Technology-I
Finally the run() method of Flask class runs