Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ITAC | Flask - Basic Flask
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
racterub
May 19, 2020
Technology
110
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
ITAC | Flask - Basic Flask
ITAC | Flask - Basic Flask
racterub
May 19, 2020
More Decks by racterub
See All by racterub
IM620 Web Security
racterub
0
160
ITAC | Websec 3
racterub
0
260
ITAC | Websec 2
racterub
0
240
ITAC | Websec 1
racterub
0
270
ITAC | Linux Basics
racterub
0
140
Introducing Reverse Engineering @ YZU CS250
racterub
0
240
ITAC | Jinja & Bootstrap
racterub
1
140
ITAC-Flask | Environment setup
racterub
1
120
Other Decks in Technology
See All in Technology
Genie Codeハンズオン応用編
taka_aki
0
140
国家プロジェクトを支える「さくらONE」 大規模LLM開発におけるGPU障害を乗り越えるクラスター運用戦略
gpuunite_official
0
270
【書籍出版記念】 10周回って、エージェント開発は RAGがすべてだった。〜RAGの歴史と開発現場で見えた実践知〜
akiratameto
20
7.1k
AI時代に、人は何を、どう学ぶのか #pbl_pub / What and How Do We Learn in the AI Era?
takaking22
1
250
AIにブラウザを触らせて、E2EテストをPlaywrightで書く
koji_kawamura
0
400
トークンマネジメントでAIにとって働きやすい環境を実現する
hikaruegashira
0
150
35分でわかるEffective Platform Engineering
nwiizo
5
620
tamachi.go 誕生の裏側
rymiyamoto
1
200
MIXIで活躍できるエンジニアを 若手社員目線で考えてみる
mixi_engineers
PRO
0
140
電話に出る Python のログの話
shinnosuke_kishida
0
220
【CEDEC2026】Creative Approaches to Localizing the Dialects and Unique Speech of Umamusume: Pretty Derby Characters in English
cygames
PRO
4
26k
LanceDB入門
mocobeta
9
680
Featured
See All Featured
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
500
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
220
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
710
Into the Great Unknown - MozCon
thekraken
41
2.7k
The Language of Interfaces
destraynor
162
27k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.5k
Darren the Foodie - Storyboard
khoart
PRO
3
3.7k
Transcript
Flask Racterub@ITAC 1
Whoami? • 電通英專⼤⼀ • 好像沒什麼好講的了 2
簡報在這 https://reurl.cc/z8Kqqy 3
Flask • Flask是⼀個使⽤Python編寫的輕量級Web應⽤框架。 • Flask沒有預設使⽤的資料庫、表單驗證⼯具,但是可以⽤ Flask-extension加入這些功能:ORM、表單驗證⼯具、檔 案上傳、各種開放式⾝分驗證技術。 4
GitHub • https://git.io/Jfe1c • 範例 Code 在這邊ㄛ,之後⼤部分會以實作為主 • 如果你裝不起來的 •
http://racterub.me:8000 • 拜託不要把他玩壞 5
起⼿式 from flask import Flask app = Flask(__name__) @app.route("/") def
hello(): return "Hello World!" if __name__ == "__main__": app.run() 6
In-url param @app.route("/db/<dbname>/<int:dbid>") def db(dbname, dbid): return "dbname: %s, dbid:
%s" % (dbname, dbid+123) 7
GET param @app.route("/get/") def get(): name = request.args.get("name") passwd =
request.args.get("passwd") return "name: %s, password: %s" % (name, passwd) 8
POST param @app.route("/post/") def post(): name = request.form["name"] passwd =
request.form["passwd"] return "name: %s, password: %s" % (name, passwd) 9
Login @app.route("/login/", methods=["POST", "GET"]) def login(): if request.method == "POST":
try: if (request.form["username"] == "test" and request.form["password"] == "test"): session["user"] = request.form["username"] return "Success" else: return redirect(url_for("login")) except ValueError: return "Something broke", 400 else: return render_template("login.html") 10
Serve static file @app.route("/robots.txt") def robot(): return send_from_directory("static", "robots.txt") 11
make_response @app.route("/makeresponse/") def makeresp(): resp = make_response("test", 200) resp.headers['X-Author'] =
"ITAC" return resp 12
render_template @app.route("/jinja/<name>") def jinja(name): return render_template("index.html", title=name) 13
Q/A 14