41 lines
992 B
Python
41 lines
992 B
Python
|
# -*- coding: utf-8 -*-
|
||
|
"""
|
||
|
StickyNotes, yet another paste bin
|
||
|
"""
|
||
|
import os
|
||
|
from ConfigParser import SafeConfigParser
|
||
|
|
||
|
from flask import Flask
|
||
|
from flask.ext.mako import MakoTemplates
|
||
|
|
||
|
from models import init_db
|
||
|
from views import views
|
||
|
|
||
|
|
||
|
def read_config():
|
||
|
"""
|
||
|
Read the configuration file and return the values in a dictionary
|
||
|
"""
|
||
|
config_file = os.path.abspath(os.path.join(os.path.dirname(__file__), u'..', u'stickynotes.cfg'))
|
||
|
config_parser = SafeConfigParser()
|
||
|
config_parser.read(config_file)
|
||
|
config = {}
|
||
|
for option in config_parser.options(u'stickynotes'):
|
||
|
config[option.upper()] = config_parser.get(u'stickynotes', option)
|
||
|
print(config)
|
||
|
return config
|
||
|
|
||
|
|
||
|
def make_app():
|
||
|
"""
|
||
|
Create the application object
|
||
|
"""
|
||
|
app = Flask(__name__)
|
||
|
# Load the config file
|
||
|
config = read_config()
|
||
|
app.config.update(config)
|
||
|
MakoTemplates(app)
|
||
|
init_db(config[u'DATABASE_URL'])
|
||
|
app.register_blueprint(views)
|
||
|
return app
|