Flask: a Micro Web Framework for Simple Things

Walker Hale

http://flask.pocoo.org/
Flask and Bottle are competeing micro web frameworks
Bottle is a single file
Use whatever comes with your distro
Say you've got a solved problem you want to throw on the web
Flask apps are WSGI apps


In [4]:
from flask import Flask, render_template
app = Flask('demo-flask')

@app.route('/')
def index():
    return 'Index page...'

@app.route('/hello')
def hello():
    return 'Hey...'

@app.route('/users/<user_name>/')
def user_profile(user_name):
    return 'Hi {0}'.format(user_name)

@app.route('/add10/<int:in_data>/')
def demo_int(in_data):
    # we're only routed here if in_data can be converted to an int
    return 10 + in_data

These represent a great opportunity for scaling down...you could do a wiki if relatively few lines of code, for example.