Created
December 12, 2012 23:59
-
-
Save Blue0ctober/4272852 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#all the imports | |
from __future__ import with_statement | |
from contextlib import closing | |
import sqlite3 | |
from flask import Flask, request, session, g, redirect, url_for, abort, render_template, flash | |
# configuration | |
DATABASE = "/tmp/flaskr.db" | |
DEBUG = True | |
SECRET_KEY = 'development key' | |
USERNAME = 'admin' | |
PASSWORD = 'default' | |
# create our little application | |
app = Flask(__name__) | |
app.config.from_envvar('FLASKR_SETTINGS', silent=True) | |
def connect_db(): | |
return sqlite3.connect(app.config['DATABASE']) | |
def init_db(): | |
with closing(connect_db()) as db: | |
with app.open_resource('schema.sql') as f: | |
db.cursor().executescript(f.read()) | |
db.commit() | |
if __name__ == '__main__': | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment