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
Sipping from a Flask
Search
Nick DiRienzo
February 02, 2013
0
160
Sipping from a Flask
A short and noobish talk on Flask. Given at BarCamp Buffalo Spring 2013.
Nick DiRienzo
February 02, 2013
Tweet
Share
More Decks by Nick DiRienzo
See All by Nick DiRienzo
How Optimizely scaled its REST API with asyncio
nickdirienzo
0
180
How to communicate effectively with the young people of today
nickdirienzo
0
35
Let's Talk Facebook
nickdirienzo
0
56
Go Code! (and other things)
nickdirienzo
1
63
Featured
See All Featured
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
18
1.7k
Principles of Awesome APIs and How to Build Them.
keavy
120
16k
How GitHub (no longer) Works
holman
304
140k
The Brand Is Dead. Long Live the Brand.
mthomps
48
28k
StorybookのUI Testing Handbookを読んだ
zakiyama
12
4.6k
Facilitating Awesome Meetings
lara
41
5.6k
The World Runs on Bad Software
bkeepers
PRO
61
6.7k
Bootstrapping a Software Product
garrettdimon
PRO
301
110k
The Cult of Friendly URLs
andyhume
74
5.7k
Why Our Code Smells
bkeepers
PRO
331
56k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
30
6k
Git: the NoSQL Database
bkeepers
PRO
422
63k
Transcript
Sipping from a Flask
@nickdirienzo UB ACM UB Hacking
ASSUMING Python: pip, virtualenv HTTP methods PostgreSQL
FLASK Microframework Flexible
LET’S GO mkdir todo && cd todo virtualenv venv --distribute
source venv/bin/activate pip install flask
app.py import flask app = flask.Flask(__name__) @app.route(‘/’) def index(): return
‘hai’ if __name__ == ‘__main__’: app.run()
DAMN GOOD DRANK
python app.py
TEMPLATING mkdir templates cd templates Jinja2 or whatever
index.html <!doctype> <html> <head> <title>Todos</title> </head> <body> <p>Hey you!</p> </body>
</html>
app.py @app.route(‘/’) def index(): return flask.render_template(‘index.html’)
app.py @app.route(‘/’) def index(): if ‘name’ in flask.request.args: name =
flask.request.args[‘name’] else: name = ‘Buffalo’ return flask.render_template(‘index.html’, name=name)
index.html <!doctype> <html> <head> <title>Todos</title> </head> <body> <p>Hey {{ name
}}!</p> </body> </html>
Still Learning ORM Third-party Modules Blueprints
Deploy App Engine DIY Heroku
Todo
Questions?