SlideShare a Scribd company logo
1 of 38
Download to read offline
Introduction to 
Flask Micro Framework 
Mohammad Reza Kamalifard 
@itmard
Codes 
https://github.com/itmard/zconf_flask_intro
What is a Web Application Framework?
What is a Web Application Framework? 
• URL Routing
What is a Web Application Framework? 
• URL Routing 
• Request and Response Objects
What is a Web Application Framework? 
• URL Routing 
• Request and Response Objects 
• Template Engine
What is a Web Application Framework? 
• URL Routing 
• Request and Response Objects 
• Template Engine 
• Development Web Server
What is a Web Application Framework? 
• URL Routing 
• Request and Response Objects 
• Template Engine 
• Development Web Server 
• Database Object Relational Mapper
What is a Web Application Framework? 
• URL Routing 
• Request and Response Objects 
• Template Engine 
• Development Web Server 
• Database Object Relational Mapper 
• Form Validation
Python for web development
Why Python? 
• Python is an easy to learn 
• Powerful 
• Clean syntax and code readability 
• Open Source 
• Cross-platform 
• Rich set of libraries 
• Large Number of open source tools
Python web frameworks 
• Django 
• Flask 
• Werkzeug 
• Tornado 
• Pyramid 
• Bottle 
•
Flask 
• Micro Framework
Flask 
• Micro Framework 
• Simple but extensible core
Flask 
• Micro Framework 
• Simple but extensible core 
• Werkzeug WSGI toolkit
Flask 
• Micro Framework 
• Simple but extensible core 
• Werkzeug WSGI toolkit 
• Jinja2 template engine
Flask 
• Micro Framework 
• Simple but extensible core 
• Werkzeug WSGI toolkit 
• Jinja2 template engine 
• Provides a simple template for web development
Flask 
• Micro Framework 
• Simple but extensible core 
• Werkzeug WSGI toolkit 
• Jinja2 template engine 
• Provides a simple template for web development 
• No ORM
Flask 
• Micro Framework 
• Simple but extensible core 
• Werkzeug WSGI toolkit 
• Jinja2 template engine 
• Provides a simple template for web development 
• No ORM 
• No Form validation
Flask 
• Micro Framework 
• Simple but extensible core 
• Werkzeug WSGI toolkit 
• Jinja2 template engine 
• Provides a simple template for web development 
• No ORM 
• No Form validation 
• Supports extensions
Simple Web Application with Flask 
from flask import Flask 
app = Flask(__name__) 
@app.route("/") 
def hello(): 
return "Welcome to ZCONF 5" 
if __name__ == "__main__": 
app.run()
Simple Web Application with Flask 
from flask import Flask 
app = Flask(__name__) 
@app.route("/") 
def hello(): 
return "Welcome to ZCONF 5" 
if __name__ == "__main__": 
app.run()
Features 
• Built in development server and debugger 
• Integrated unit testing support 
• RESTful request dispatching 
• Uses Jinja2 templating 
• Support for secure cookies (client side sessions) 
• 100% WSGI 1.0 compliant 
• Unicode based 
• Extensively documented
Flask Routing 
• Modern web applications have beautiful URLs 
• Routing using decorators 
• route( ) decorator is used to bind a function to a URL 
• Make certain parts of the URL dynamic 
• Attach multiple rules to a function
Flask Routing 
• Modern web applications have beautiful URLs 
• Routing using decorators 
• route( ) decorator is used to bind a function to a URL 
• Make certain parts of the URL dynamic 
• Attach multiple rules to a function 
@app.route('/') 
def index(): 
return 'Index Page' 
@app.route('/hello/') 
def hello(): 
return 'Hello World'
Variable Rules 
• <variable_name> 
@app.route('/user/<username>') 
def show_user_profile(username): 
return 'User %s' % username 
• <converter:variable_name> 
@app.route('/post/<int:post_id>') 
def show_post(post_id): 
return 'Post %d' % post_id
Request Object 
• Easy way to access request data 
@app.route('/login', methods=['POST', 'GET']) 
def login(): 
error = None 
if request.method == 'POST': 
if valid_login(request.form['username'],request.form['password']): 
return log_the_user_in(request.form['username']) 
else: 
error = 'Invalid username/password' 
return render_template(' login.html ', error=error)
Template Engine 
• Jinja2 (default) 
from flask import render_template 
@app.route(' /hello/ ') 
@app.route(' /hello/<name> ') 
def hello(name=None): 
return render_template(' hello.html', name=name)
hello.html 
<!doctype html> 
<title>Hello from Flask</title> 
{% if name %} 
<h1>Hello {{ name }}!</h1> 
{% else %} 
<h1>Hello World!</h1> 
{% endif %}
Development server and debugger 
• Easy to use local development server 
• Interactive Error page with debug mode
Database management 
• No ORM inside flask 
• Extensions: 
• SQLAlchemy 
• Peewee 
• Mongoengine 
• MongoKIT 
• PyMongo 
• MongoAlchemy 
• Flask-CouchDB 
• Flask-FluidDB 
• Flask-CouchDBKit 
• Flask-FluidDB
#sqlalchemy 
from flask import Flask 
from flask.ext.sqlalchemy import SQLAlchemy 
app = Flask(__name__) 
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db' 
db = SQLAlchemy(app) 
class User(db.Model): 
id = db.Column(db.Integer, primary_key=True) 
username = db.Column(db.String(80), unique=True) 
email = db.Column(db.String(120), unique=True) 
#peewee 
import datetime 
from peewee import * 
class Note(db.Model): 
message = TextField() 
created = DateTimeField(default=datetime.datetime.now)
Form validation 
• Flask WTForm 
#class based forms 
from flask_wtf import Form 
from wtforms import StringField 
from wtforms.validators import DataRequired 
class MyForm(Form): 
name = StringField('name', validators=[DataRequired()]) 
#view 
@app.route('/submit', methods=('GET', 'POST')) 
def submit(): 
form = MyForm() 
if form.validate_on_submit(): 
return redirect('/success') 
return render_template('submit.html', form=form)
Architectural Pattern 
• Single file application 
• MVC , MV* patterns 
project 
--apps 
----------app1 
----------------models.py 
----------------views.py 
---------------forms.py 
---------------apis.py 
---statics 
---templates 
-----models 
-----views 
-----forms 
-----statics 
-----templates
Mohammad Efazati 
Mehdi Khoshnody 
Reza Shalbafzadeh 
K1 Hedayati 
Thank you :)
Copyright 2014 Mohammad Reza Kamalifard 
All rights reserved. 
Introduction to Flask by Mohammad Reza Kamalifard is licensed under a 
Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International 
License. 
ZCONF 5

More Related Content

What's hot

BUILDING MODERN PYTHON WEB FRAMEWORKS USING FLASK WITH NEIL GREY
BUILDING MODERN PYTHON WEB FRAMEWORKS USING FLASK WITH NEIL GREYBUILDING MODERN PYTHON WEB FRAMEWORKS USING FLASK WITH NEIL GREY
BUILDING MODERN PYTHON WEB FRAMEWORKS USING FLASK WITH NEIL GREYCodeCore
 
Flask restfulservices
Flask restfulservicesFlask restfulservices
Flask restfulservicesMarcos Lin
 
8 Minutes On Rack
8 Minutes On Rack8 Minutes On Rack
8 Minutes On Rackdanwrong
 
Node.js API 서버 성능 개선기
Node.js API 서버 성능 개선기Node.js API 서버 성능 개선기
Node.js API 서버 성능 개선기JeongHun Byeon
 
Beyond PHP - it's not (just) about the code
Beyond PHP - it's not (just) about the codeBeyond PHP - it's not (just) about the code
Beyond PHP - it's not (just) about the codeWim Godden
 
Real time server
Real time serverReal time server
Real time serverthepian
 
When dynamic becomes static: the next step in web caching techniques
When dynamic becomes static: the next step in web caching techniquesWhen dynamic becomes static: the next step in web caching techniques
When dynamic becomes static: the next step in web caching techniquesWim Godden
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to TornadoGavin Roy
 
Reliable Python REST API (by Volodymyr Hotsyk) - Web Back-End Tech Hangout - ...
Reliable Python REST API (by Volodymyr Hotsyk) - Web Back-End Tech Hangout - ...Reliable Python REST API (by Volodymyr Hotsyk) - Web Back-End Tech Hangout - ...
Reliable Python REST API (by Volodymyr Hotsyk) - Web Back-End Tech Hangout - ...Innovecs
 
Bootstrapping multidc observability stack
Bootstrapping multidc observability stackBootstrapping multidc observability stack
Bootstrapping multidc observability stackBram Vogelaar
 
Securing Prometheus exporters using HashiCorp Vault
Securing Prometheus exporters using HashiCorp VaultSecuring Prometheus exporters using HashiCorp Vault
Securing Prometheus exporters using HashiCorp VaultBram Vogelaar
 
Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4Ilya Haykinson
 
What happens in laravel 4 bootstraping
What happens in laravel 4 bootstrapingWhat happens in laravel 4 bootstraping
What happens in laravel 4 bootstrapingJace Ju
 
Asynchronous web apps with the Play Framework 2.0
Asynchronous web apps with the Play Framework 2.0Asynchronous web apps with the Play Framework 2.0
Asynchronous web apps with the Play Framework 2.0Oscar Renalias
 
Building a real life application in node js
Building a real life application in node jsBuilding a real life application in node js
Building a real life application in node jsfakedarren
 
Roll Your Own API Management Platform with nginx and Lua
Roll Your Own API Management Platform with nginx and LuaRoll Your Own API Management Platform with nginx and Lua
Roll Your Own API Management Platform with nginx and LuaJon Moore
 

What's hot (20)

Rest api with Python
Rest api with PythonRest api with Python
Rest api with Python
 
BUILDING MODERN PYTHON WEB FRAMEWORKS USING FLASK WITH NEIL GREY
BUILDING MODERN PYTHON WEB FRAMEWORKS USING FLASK WITH NEIL GREYBUILDING MODERN PYTHON WEB FRAMEWORKS USING FLASK WITH NEIL GREY
BUILDING MODERN PYTHON WEB FRAMEWORKS USING FLASK WITH NEIL GREY
 
Flask restfulservices
Flask restfulservicesFlask restfulservices
Flask restfulservices
 
8 Minutes On Rack
8 Minutes On Rack8 Minutes On Rack
8 Minutes On Rack
 
Node.js API 서버 성능 개선기
Node.js API 서버 성능 개선기Node.js API 서버 성능 개선기
Node.js API 서버 성능 개선기
 
Beyond PHP - it's not (just) about the code
Beyond PHP - it's not (just) about the codeBeyond PHP - it's not (just) about the code
Beyond PHP - it's not (just) about the code
 
Real time server
Real time serverReal time server
Real time server
 
When dynamic becomes static: the next step in web caching techniques
When dynamic becomes static: the next step in web caching techniquesWhen dynamic becomes static: the next step in web caching techniques
When dynamic becomes static: the next step in web caching techniques
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
 
Rack Middleware
Rack MiddlewareRack Middleware
Rack Middleware
 
Reliable Python REST API (by Volodymyr Hotsyk) - Web Back-End Tech Hangout - ...
Reliable Python REST API (by Volodymyr Hotsyk) - Web Back-End Tech Hangout - ...Reliable Python REST API (by Volodymyr Hotsyk) - Web Back-End Tech Hangout - ...
Reliable Python REST API (by Volodymyr Hotsyk) - Web Back-End Tech Hangout - ...
 
Bootstrapping multidc observability stack
Bootstrapping multidc observability stackBootstrapping multidc observability stack
Bootstrapping multidc observability stack
 
Securing Prometheus exporters using HashiCorp Vault
Securing Prometheus exporters using HashiCorp VaultSecuring Prometheus exporters using HashiCorp Vault
Securing Prometheus exporters using HashiCorp Vault
 
Beyond Phoenix
Beyond PhoenixBeyond Phoenix
Beyond Phoenix
 
Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4
 
What happens in laravel 4 bootstraping
What happens in laravel 4 bootstrapingWhat happens in laravel 4 bootstraping
What happens in laravel 4 bootstraping
 
Asynchronous web apps with the Play Framework 2.0
Asynchronous web apps with the Play Framework 2.0Asynchronous web apps with the Play Framework 2.0
Asynchronous web apps with the Play Framework 2.0
 
Building a real life application in node js
Building a real life application in node jsBuilding a real life application in node js
Building a real life application in node js
 
Powershell Demo Presentation
Powershell Demo PresentationPowershell Demo Presentation
Powershell Demo Presentation
 
Roll Your Own API Management Platform with nginx and Lua
Roll Your Own API Management Platform with nginx and LuaRoll Your Own API Management Platform with nginx and Lua
Roll Your Own API Management Platform with nginx and Lua
 

Similar to Introduction to Flask Micro Framework

DEF CON 24 - workshop - Craig Young - brainwashing embedded systems
DEF CON 24 - workshop - Craig Young - brainwashing embedded systemsDEF CON 24 - workshop - Craig Young - brainwashing embedded systems
DEF CON 24 - workshop - Craig Young - brainwashing embedded systemsFelipe Prado
 
Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5Ganesh Kondal
 
web2py:Web development like a boss
web2py:Web development like a bossweb2py:Web development like a boss
web2py:Web development like a bossFrancisco Ribeiro
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...Malin Weiss
 
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...Speedment, Inc.
 
Next Generation Spring MVC with Spring Roo
Next Generation Spring MVC with Spring RooNext Generation Spring MVC with Spring Roo
Next Generation Spring MVC with Spring RooStefan Schmidt
 
Node.js to the rescue
Node.js to the rescueNode.js to the rescue
Node.js to the rescueMarko Heijnen
 
Microsoft Power Page for Developer - ภาษาไทย
Microsoft Power Page for Developer - ภาษาไทยMicrosoft Power Page for Developer - ภาษาไทย
Microsoft Power Page for Developer - ภาษาไทยTeerasej Jiraphatchandej
 
Integrating Alfresco with Portals
Integrating Alfresco with PortalsIntegrating Alfresco with Portals
Integrating Alfresco with PortalsPiergiorgio Lucidi
 
CFWheels - Pragmatic, Beautiful Code
CFWheels - Pragmatic, Beautiful CodeCFWheels - Pragmatic, Beautiful Code
CFWheels - Pragmatic, Beautiful Codeindiver
 
Create Rest API in Nodejs
Create Rest API in Nodejs Create Rest API in Nodejs
Create Rest API in Nodejs Irfan Maulana
 
SOLID Programming with Portable Class Libraries
SOLID Programming with Portable Class LibrariesSOLID Programming with Portable Class Libraries
SOLID Programming with Portable Class LibrariesVagif Abilov
 
Structured Functional Automated Web Service Testing
Structured Functional Automated Web Service TestingStructured Functional Automated Web Service Testing
Structured Functional Automated Web Service Testingrdekleijn
 
Web Application Frameworks (WAF)
Web Application Frameworks (WAF)Web Application Frameworks (WAF)
Web Application Frameworks (WAF)Ako Kaman
 
PLAT-7 Spring Web Scripts and Spring Surf
PLAT-7 Spring Web Scripts and Spring SurfPLAT-7 Spring Web Scripts and Spring Surf
PLAT-7 Spring Web Scripts and Spring SurfAlfresco Software
 
PLAT-7 Spring Web Scripts and Spring Surf
PLAT-7 Spring Web Scripts and Spring SurfPLAT-7 Spring Web Scripts and Spring Surf
PLAT-7 Spring Web Scripts and Spring SurfAlfresco Software
 
Groovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationGroovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationStuart (Pid) Williams
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1Mohammad Qureshi
 

Similar to Introduction to Flask Micro Framework (20)

DEF CON 24 - workshop - Craig Young - brainwashing embedded systems
DEF CON 24 - workshop - Craig Young - brainwashing embedded systemsDEF CON 24 - workshop - Craig Young - brainwashing embedded systems
DEF CON 24 - workshop - Craig Young - brainwashing embedded systems
 
Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5
 
web2py:Web development like a boss
web2py:Web development like a bossweb2py:Web development like a boss
web2py:Web development like a boss
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
 
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
 
Next Generation Spring MVC with Spring Roo
Next Generation Spring MVC with Spring RooNext Generation Spring MVC with Spring Roo
Next Generation Spring MVC with Spring Roo
 
Rhodes
RhodesRhodes
Rhodes
 
Node.js to the rescue
Node.js to the rescueNode.js to the rescue
Node.js to the rescue
 
Microsoft Power Page for Developer - ภาษาไทย
Microsoft Power Page for Developer - ภาษาไทยMicrosoft Power Page for Developer - ภาษาไทย
Microsoft Power Page for Developer - ภาษาไทย
 
Integrating Alfresco with Portals
Integrating Alfresco with PortalsIntegrating Alfresco with Portals
Integrating Alfresco with Portals
 
CFWheels - Pragmatic, Beautiful Code
CFWheels - Pragmatic, Beautiful CodeCFWheels - Pragmatic, Beautiful Code
CFWheels - Pragmatic, Beautiful Code
 
Create Rest API in Nodejs
Create Rest API in Nodejs Create Rest API in Nodejs
Create Rest API in Nodejs
 
SOLID Programming with Portable Class Libraries
SOLID Programming with Portable Class LibrariesSOLID Programming with Portable Class Libraries
SOLID Programming with Portable Class Libraries
 
Structured Functional Automated Web Service Testing
Structured Functional Automated Web Service TestingStructured Functional Automated Web Service Testing
Structured Functional Automated Web Service Testing
 
Web Application Frameworks (WAF)
Web Application Frameworks (WAF)Web Application Frameworks (WAF)
Web Application Frameworks (WAF)
 
PLAT-7 Spring Web Scripts and Spring Surf
PLAT-7 Spring Web Scripts and Spring SurfPLAT-7 Spring Web Scripts and Spring Surf
PLAT-7 Spring Web Scripts and Spring Surf
 
PLAT-7 Spring Web Scripts and Spring Surf
PLAT-7 Spring Web Scripts and Spring SurfPLAT-7 Spring Web Scripts and Spring Surf
PLAT-7 Spring Web Scripts and Spring Surf
 
Groovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationGroovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentation
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
ITB2017 - Keynote
ITB2017 - KeynoteITB2017 - Keynote
ITB2017 - Keynote
 

More from Mohammad Reza Kamalifard

Tehlug 26 Nov 2013 Hackers,Cyberwarfare and Online privacy
Tehlug 26 Nov 2013 Hackers,Cyberwarfare and Online privacyTehlug 26 Nov 2013 Hackers,Cyberwarfare and Online privacy
Tehlug 26 Nov 2013 Hackers,Cyberwarfare and Online privacyMohammad Reza Kamalifard
 
جلسه دوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه دوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲جلسه دوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه دوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲Mohammad Reza Kamalifard
 
جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲Mohammad Reza Kamalifard
 
جلسه چهارم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه چهارم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲جلسه چهارم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه چهارم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲Mohammad Reza Kamalifard
 
جلسه پنجم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۱
جلسه پنجم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۱جلسه پنجم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۱
جلسه پنجم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۱Mohammad Reza Kamalifard
 
جلسه پنجم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۲
جلسه پنجم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۲جلسه پنجم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۲
جلسه پنجم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۲Mohammad Reza Kamalifard
 
جلسه ششم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۱
جلسه ششم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۱جلسه ششم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۱
جلسه ششم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۱Mohammad Reza Kamalifard
 
جلسه ششم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۲
جلسه ششم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۲جلسه ششم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۲
جلسه ششم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۲Mohammad Reza Kamalifard
 
جلسه هفتم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه هفتم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲جلسه هفتم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه هفتم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲Mohammad Reza Kamalifard
 
جلسه اول پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه اول پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲جلسه اول پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه اول پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲Mohammad Reza Kamalifard
 
اسلاید اول جلسه اول دوره پاییز کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه اول دوره پاییز کلاس پایتون برای هکرهای قانونیاسلاید اول جلسه اول دوره پاییز کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه اول دوره پاییز کلاس پایتون برای هکرهای قانونیMohammad Reza Kamalifard
 
اسلاید دوم جلسه یازدهم کلاس پایتون برای هکر های قانونی
اسلاید دوم جلسه یازدهم کلاس پایتون برای هکر های قانونیاسلاید دوم جلسه یازدهم کلاس پایتون برای هکر های قانونی
اسلاید دوم جلسه یازدهم کلاس پایتون برای هکر های قانونیMohammad Reza Kamalifard
 
اسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونیاسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونیMohammad Reza Kamalifard
 
اسلاید ارائه دوم جلسه ۱۰ کلاس پایتون برای هکر های قانونی
اسلاید ارائه دوم جلسه ۱۰ کلاس پایتون برای هکر های قانونی اسلاید ارائه دوم جلسه ۱۰ کلاس پایتون برای هکر های قانونی
اسلاید ارائه دوم جلسه ۱۰ کلاس پایتون برای هکر های قانونی Mohammad Reza Kamalifard
 
اسلاید ارائه اول جلسه ۱۰ کلاس پایتون برای هکر های قانونی
اسلاید ارائه اول جلسه ۱۰ کلاس پایتون برای هکر های قانونی اسلاید ارائه اول جلسه ۱۰ کلاس پایتون برای هکر های قانونی
اسلاید ارائه اول جلسه ۱۰ کلاس پایتون برای هکر های قانونی Mohammad Reza Kamalifard
 
اسلاید ارائه سوم جلسه ۱۰ کلاس پایتون برای هکر های قانونی
اسلاید ارائه سوم جلسه ۱۰ کلاس پایتون برای هکر های قانونی اسلاید ارائه سوم جلسه ۱۰ کلاس پایتون برای هکر های قانونی
اسلاید ارائه سوم جلسه ۱۰ کلاس پایتون برای هکر های قانونی Mohammad Reza Kamalifard
 
اسلاید جلسه ۹ کلاس پایتون برای هکر های قانونی
اسلاید جلسه ۹ کلاس پایتون برای هکر های قانونیاسلاید جلسه ۹ کلاس پایتون برای هکر های قانونی
اسلاید جلسه ۹ کلاس پایتون برای هکر های قانونیMohammad Reza Kamalifard
 
اسلاید اول جلسه هشتم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه هشتم کلاس پایتون برای هکرهای قانونیاسلاید اول جلسه هشتم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه هشتم کلاس پایتون برای هکرهای قانونیMohammad Reza Kamalifard
 
اسلاید سوم جلسه هفتم کلاس پایتون برای هکرهای قانونی
اسلاید سوم جلسه هفتم کلاس پایتون برای هکرهای قانونیاسلاید سوم جلسه هفتم کلاس پایتون برای هکرهای قانونی
اسلاید سوم جلسه هفتم کلاس پایتون برای هکرهای قانونیMohammad Reza Kamalifard
 

More from Mohammad Reza Kamalifard (20)

Internet Age
Internet AgeInternet Age
Internet Age
 
Tehlug 26 Nov 2013 Hackers,Cyberwarfare and Online privacy
Tehlug 26 Nov 2013 Hackers,Cyberwarfare and Online privacyTehlug 26 Nov 2013 Hackers,Cyberwarfare and Online privacy
Tehlug 26 Nov 2013 Hackers,Cyberwarfare and Online privacy
 
جلسه دوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه دوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲جلسه دوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه دوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
 
جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
 
جلسه چهارم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه چهارم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲جلسه چهارم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه چهارم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
 
جلسه پنجم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۱
جلسه پنجم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۱جلسه پنجم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۱
جلسه پنجم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۱
 
جلسه پنجم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۲
جلسه پنجم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۲جلسه پنجم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۲
جلسه پنجم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۲
 
جلسه ششم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۱
جلسه ششم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۱جلسه ششم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۱
جلسه ششم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۱
 
جلسه ششم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۲
جلسه ششم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۲جلسه ششم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۲
جلسه ششم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۲
 
جلسه هفتم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه هفتم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲جلسه هفتم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه هفتم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
 
جلسه اول پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه اول پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲جلسه اول پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه اول پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
 
اسلاید اول جلسه اول دوره پاییز کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه اول دوره پاییز کلاس پایتون برای هکرهای قانونیاسلاید اول جلسه اول دوره پاییز کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه اول دوره پاییز کلاس پایتون برای هکرهای قانونی
 
اسلاید دوم جلسه یازدهم کلاس پایتون برای هکر های قانونی
اسلاید دوم جلسه یازدهم کلاس پایتون برای هکر های قانونیاسلاید دوم جلسه یازدهم کلاس پایتون برای هکر های قانونی
اسلاید دوم جلسه یازدهم کلاس پایتون برای هکر های قانونی
 
اسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونیاسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونی
 
اسلاید ارائه دوم جلسه ۱۰ کلاس پایتون برای هکر های قانونی
اسلاید ارائه دوم جلسه ۱۰ کلاس پایتون برای هکر های قانونی اسلاید ارائه دوم جلسه ۱۰ کلاس پایتون برای هکر های قانونی
اسلاید ارائه دوم جلسه ۱۰ کلاس پایتون برای هکر های قانونی
 
اسلاید ارائه اول جلسه ۱۰ کلاس پایتون برای هکر های قانونی
اسلاید ارائه اول جلسه ۱۰ کلاس پایتون برای هکر های قانونی اسلاید ارائه اول جلسه ۱۰ کلاس پایتون برای هکر های قانونی
اسلاید ارائه اول جلسه ۱۰ کلاس پایتون برای هکر های قانونی
 
اسلاید ارائه سوم جلسه ۱۰ کلاس پایتون برای هکر های قانونی
اسلاید ارائه سوم جلسه ۱۰ کلاس پایتون برای هکر های قانونی اسلاید ارائه سوم جلسه ۱۰ کلاس پایتون برای هکر های قانونی
اسلاید ارائه سوم جلسه ۱۰ کلاس پایتون برای هکر های قانونی
 
اسلاید جلسه ۹ کلاس پایتون برای هکر های قانونی
اسلاید جلسه ۹ کلاس پایتون برای هکر های قانونیاسلاید جلسه ۹ کلاس پایتون برای هکر های قانونی
اسلاید جلسه ۹ کلاس پایتون برای هکر های قانونی
 
اسلاید اول جلسه هشتم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه هشتم کلاس پایتون برای هکرهای قانونیاسلاید اول جلسه هشتم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه هشتم کلاس پایتون برای هکرهای قانونی
 
اسلاید سوم جلسه هفتم کلاس پایتون برای هکرهای قانونی
اسلاید سوم جلسه هفتم کلاس پایتون برای هکرهای قانونیاسلاید سوم جلسه هفتم کلاس پایتون برای هکرهای قانونی
اسلاید سوم جلسه هفتم کلاس پایتون برای هکرهای قانونی
 

Recently uploaded

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 

Introduction to Flask Micro Framework

  • 1. Introduction to Flask Micro Framework Mohammad Reza Kamalifard @itmard
  • 3. What is a Web Application Framework?
  • 4. What is a Web Application Framework? • URL Routing
  • 5. What is a Web Application Framework? • URL Routing • Request and Response Objects
  • 6. What is a Web Application Framework? • URL Routing • Request and Response Objects • Template Engine
  • 7. What is a Web Application Framework? • URL Routing • Request and Response Objects • Template Engine • Development Web Server
  • 8. What is a Web Application Framework? • URL Routing • Request and Response Objects • Template Engine • Development Web Server • Database Object Relational Mapper
  • 9. What is a Web Application Framework? • URL Routing • Request and Response Objects • Template Engine • Development Web Server • Database Object Relational Mapper • Form Validation
  • 10. Python for web development
  • 11. Why Python? • Python is an easy to learn • Powerful • Clean syntax and code readability • Open Source • Cross-platform • Rich set of libraries • Large Number of open source tools
  • 12. Python web frameworks • Django • Flask • Werkzeug • Tornado • Pyramid • Bottle •
  • 13.
  • 14. Flask • Micro Framework
  • 15. Flask • Micro Framework • Simple but extensible core
  • 16. Flask • Micro Framework • Simple but extensible core • Werkzeug WSGI toolkit
  • 17. Flask • Micro Framework • Simple but extensible core • Werkzeug WSGI toolkit • Jinja2 template engine
  • 18. Flask • Micro Framework • Simple but extensible core • Werkzeug WSGI toolkit • Jinja2 template engine • Provides a simple template for web development
  • 19. Flask • Micro Framework • Simple but extensible core • Werkzeug WSGI toolkit • Jinja2 template engine • Provides a simple template for web development • No ORM
  • 20. Flask • Micro Framework • Simple but extensible core • Werkzeug WSGI toolkit • Jinja2 template engine • Provides a simple template for web development • No ORM • No Form validation
  • 21. Flask • Micro Framework • Simple but extensible core • Werkzeug WSGI toolkit • Jinja2 template engine • Provides a simple template for web development • No ORM • No Form validation • Supports extensions
  • 22. Simple Web Application with Flask from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Welcome to ZCONF 5" if __name__ == "__main__": app.run()
  • 23. Simple Web Application with Flask from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Welcome to ZCONF 5" if __name__ == "__main__": app.run()
  • 24. Features • Built in development server and debugger • Integrated unit testing support • RESTful request dispatching • Uses Jinja2 templating • Support for secure cookies (client side sessions) • 100% WSGI 1.0 compliant • Unicode based • Extensively documented
  • 25. Flask Routing • Modern web applications have beautiful URLs • Routing using decorators • route( ) decorator is used to bind a function to a URL • Make certain parts of the URL dynamic • Attach multiple rules to a function
  • 26. Flask Routing • Modern web applications have beautiful URLs • Routing using decorators • route( ) decorator is used to bind a function to a URL • Make certain parts of the URL dynamic • Attach multiple rules to a function @app.route('/') def index(): return 'Index Page' @app.route('/hello/') def hello(): return 'Hello World'
  • 27. Variable Rules • <variable_name> @app.route('/user/<username>') def show_user_profile(username): return 'User %s' % username • <converter:variable_name> @app.route('/post/<int:post_id>') def show_post(post_id): return 'Post %d' % post_id
  • 28. Request Object • Easy way to access request data @app.route('/login', methods=['POST', 'GET']) def login(): error = None if request.method == 'POST': if valid_login(request.form['username'],request.form['password']): return log_the_user_in(request.form['username']) else: error = 'Invalid username/password' return render_template(' login.html ', error=error)
  • 29. Template Engine • Jinja2 (default) from flask import render_template @app.route(' /hello/ ') @app.route(' /hello/<name> ') def hello(name=None): return render_template(' hello.html', name=name)
  • 30. hello.html <!doctype html> <title>Hello from Flask</title> {% if name %} <h1>Hello {{ name }}!</h1> {% else %} <h1>Hello World!</h1> {% endif %}
  • 31. Development server and debugger • Easy to use local development server • Interactive Error page with debug mode
  • 32.
  • 33. Database management • No ORM inside flask • Extensions: • SQLAlchemy • Peewee • Mongoengine • MongoKIT • PyMongo • MongoAlchemy • Flask-CouchDB • Flask-FluidDB • Flask-CouchDBKit • Flask-FluidDB
  • 34. #sqlalchemy from flask import Flask from flask.ext.sqlalchemy import SQLAlchemy app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db' db = SQLAlchemy(app) class User(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(80), unique=True) email = db.Column(db.String(120), unique=True) #peewee import datetime from peewee import * class Note(db.Model): message = TextField() created = DateTimeField(default=datetime.datetime.now)
  • 35. Form validation • Flask WTForm #class based forms from flask_wtf import Form from wtforms import StringField from wtforms.validators import DataRequired class MyForm(Form): name = StringField('name', validators=[DataRequired()]) #view @app.route('/submit', methods=('GET', 'POST')) def submit(): form = MyForm() if form.validate_on_submit(): return redirect('/success') return render_template('submit.html', form=form)
  • 36. Architectural Pattern • Single file application • MVC , MV* patterns project --apps ----------app1 ----------------models.py ----------------views.py ---------------forms.py ---------------apis.py ---statics ---templates -----models -----views -----forms -----statics -----templates
  • 37. Mohammad Efazati Mehdi Khoshnody Reza Shalbafzadeh K1 Hedayati Thank you :)
  • 38. Copyright 2014 Mohammad Reza Kamalifard All rights reserved. Introduction to Flask by Mohammad Reza Kamalifard is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. ZCONF 5