-
-
Save solarce/4272890 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(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() |
Author
solarce
commented
Dec 13, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment