To request database connections, flaskr uses decorators. For example: @app.before_request def before_request(): g.db = connect_db() From http://stackoverflow.com/questions/739654/understanding-python-decorators: Functions are objects in python and can be assigned to a variable. Functions can be embedded inside other functions, but the inner function is