Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Introduction to Flask
Search
Sébastien Fievet
February 23, 2017
Technology
77
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Introduction to Flask
Workshop given for a Swisscom Digital Lab meetup at EPFL
Sébastien Fievet
February 23, 2017
More Decks by Sébastien Fievet
See All by Sébastien Fievet
Django Round-Up – Meetup Django CH #28
zyegfryed
0
69
Django Round-Up – Meetup Django CH #25
zyegfryed
0
61
Django Round-Up – Meetup Django CH #23
zyegfryed
0
59
Django Round-Up – Meetup Django CH #21
zyegfryed
0
79
Django Round-Up – Meetup Django CH #20
zyegfryed
0
84
Django Round-Up – Meetup Django CH #19
zyegfryed
2
93
[Django] URL prefix with runserver
zyegfryed
0
1.5k
[Django] Generating PDF with PDFForm
zyegfryed
0
97
[Django] RESTful API
zyegfryed
1
230
Other Decks in Technology
See All in Technology
AI時代だからこそ推したい!Gitコマンド再入門
munakata
0
180
遠藤な_めぐろLT #38 「社内のAI活用推進」@麻布台_20261009
endonanana
0
120
AI時代のPRレビューにどう向き合うか?
kairim0
1
220
組み立てて楽しむ AWS Blocks 入門
kmiya84377
0
230
脆弱性診断って、何をしているの? 〜弱点を見つけて、会社の改善につなげるまで〜
keeg
0
880
Classmethod Company Deck
satoshi7
0
140
【Data Engineering Summit2026_登壇資料】医療ビッグデータ×AIエージェントを支えるデータ基盤とハーネスエンジニアリング
jmdc_presentation
0
140
ブラウザとサーバーから考えるAI時代のフロントエンド監視
shogo4131
3
870
会社説明資料
persolserverworks
0
9.7k
Benchmarking Disaggregated Serving on vLLM + Dynamo with a Real Coding-Agent Workload
nttcom
0
120
日本語に強いオープンな大規模言語モデル「LLM-jp」
odashi
3
730
宣言型部分更新は何を解決しどこへ向かうのか
shuta13
1
340
Featured
See All Featured
How to Ace a Technical Interview
jacobian
280
24k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
Documentation Writing (for coders)
carmenintech
77
5.6k
Designing for Performance
lara
612
70k
Build your cross-platform service in a week with App Engine
jlugia
234
19k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
750
The untapped power of vector embeddings
frankvandijk
2
1.9k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
The Invisible Side of Design
smashingmag
301
52k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
520
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
570
Navigating Team Friction
lara
192
16k
Transcript
Introduction to Flask Sébastien Fievet Swisscom Digital Lab at EPFL
Prerequisites
$ python --version Python 2.7.12 https://www.python.org/downloads
$ pip --version pip 9.0.1 https://pip.pypa.io/en/stable/installing/
$ pip install virtualenv $ virtualenv --version 13.1.2 https://virtualenv.pypa.io/en/stable/installation/
$ git clone \ https://github.com/zyegfryed/intro_to_flask.git $ cd intro_to_flask $ virtualenv
.venv $ source .venv/bin/activate
Hello Flask!
–Deny “What… Why Flask?”
–http://flask.pocoo.org/ “Flask is a microframework for Python based on Werkzeug,
Jinja 2 and good intentions.”
Diving In https://github.com/zyegfryed/intro_to_flask/tree/01_intro
$ pip install Flask http://flask.pocoo.org/docs/0.12/installation/
# app.y from flask import Flask app = Flask(__name__) @app.route('/')
def hello_world(): return 'Hello, World!'
$ git checkout 01_intro $ export FLASK_APP=app.py $ flask run
$ curl http://127.0.0.1:5000/ Hello, World!
Chatbot
Diving In https://github.com/zyegfryed/intro_to_flask/tree/02_chatbot
$ pip install fbmessenger https://github.com/rehabstudio/fbmessenger
# app.py @app.route('/webhook', methods=['GET', 'POST']) def webhook(): if request.method ==
'GET': if request.args.get('hub.verify_token') == \ os.environ.get('FB_VERIFY_TOKEN'): return request.args.get('hub.challenge') raise ValueError('FB_VERIFY_TOKEN does not match.')
# app.py @app.route('/webhook', methods=['GET', 'POST']) def webhook(): […] elif request.method
== 'POST': messenger.handle(request.get_json(force=True)) return ''
# app.py from fbmessenger import BaseMessenger from fbmessenger import elements
class Messenger(BaseMessenger): def message(self, message): element = elements.Text('Received: {0}’.format( message['message']['text'])) self.send(element.to_dict()) […]
# app.py messenger = \ Messenger(os.environ.get(‘FB_PAGE_TOKEN’))
$ ngrok --version ngrok version 2.1.18 https://ngrok.com/download
Messenger https://developers.facebook.com/docs/messenger- platform/guides/setup
$ git checkout 02_chatbot $ export FB_VERIFY_TOKEN=… $ export FB_PAGE_TOKEN=…
$ flask run - - - - - - - - - — - - - - - - - - - - - - $ ngrok http 5000
Async
Diving In https://github.com/zyegfryed/intro_to_flask/tree/03_async
# app.py from redis import StrictRedis redis = StrictRedis() @job('default',
connection=redis) def messenger_handle(message): messenger.handle(message) @app.route('/webhook', methods=['GET', 'POST']) def webhook(): […] elif request.method == 'POST': messenger_handle.delay(request.get_json(force=True)) return ''
$ redis-server --version Redis server v=3.2.8 https://redis.io/download
$ pip install rq http://python-rq.org/
$ git checkout 03_async $ export FB_PAGE_TOKEN=… $ rqworker default
- - - - - - - - - — - - - - - - - - - - - - $ redis-server
Links • https://github.com/zyegfryed/intro_to_flask • https://www.python.org/downloads/ • https://pip.pypa.io/en/stable/installing/ • http://flask.pocoo.org/ •
http://flask.pocoo.org/docs/0.12/quickstart/ • https://developers.facebook.com/docs/messenger-platform/guides/setup • https://github.com/rehabstudio/fbmessenger • https://redis.io/download • http://python-rq.org/ • https://github.com/rehabstudio/fbmessenger