Skip to content

Instantly share code, notes, and snippets.

@Blue0ctober
Created December 12, 2012 23:59
Show Gist options
  • Save Blue0ctober/4272852 to your computer and use it in GitHub Desktop.
Save Blue0ctober/4272852 to your computer and use it in GitHub Desktop.
#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