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
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
150
ITAC | Websec 3
racterub
0
250
ITAC | Websec 2
racterub
0
220
ITAC | Websec 1
racterub
0
260
ITAC | Linux Basics
racterub
0
130
Introducing Reverse Engineering @ YZU CS250
racterub
0
240
ITAC | Jinja & Bootstrap
racterub
1
120
ITAC-Flask | Environment setup
racterub
1
100
Other Decks in Technology
See All in Technology
Agentic AI時代における メルカリのAIガバナンスとガードレール実装
naoichihara
16
17k
開発を止めない CI/CD ~CI Visibilityによる継続的最適化~
pensuke628
0
200
人が担う「価値」とは?これからの「QA」とは / Human Value and the Future of Quality Assurance
bitkey
PRO
0
140
Java正規表現エンジン(NFA)の仕組みと パフォーマンスを維持するための最適化手法
takeuchi_132917
0
150
long-running-tasks
cipepser
2
440
インフラが苦手でも大丈夫! 紙芝居 Kubernetes -WWGT 10周年編-
aoi1
1
310
TROCCOで始めるクラウドコストを民主化するためのFinOps
tk3fftk
1
300
Agentic Design Patterns
glaforge
0
280
AIガバナンス実践 - 生成AIコネクタのデータ漏洩リスクと実務対策
knishioka
0
140
権限管理設計を完全に理解した
rsugi
2
240
string地獄を脱出する
sansantech
PRO
1
100
最低限これだけ押さえれ大丈夫_Claude Enterprise/Team企業展開ガバナンス入門
tkikuchi
1
540
Featured
See All Featured
Code Reviewing Like a Champion
maltzj
528
40k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
210
Building Applications with DynamoDB
mza
96
7.1k
30 Presentation Tips
portentint
PRO
1
310
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
160
Design in an AI World
tapps
1
220
Producing Creativity
orderedlist
PRO
348
40k
A Tale of Four Properties
chriscoyier
163
24k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
590
エンジニアに許された特別な時間の終わり
watany
107
240k
RailsConf 2023
tenderlove
30
1.5k
How to Ace a Technical Interview
jacobian
281
24k
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