43 lines
989 B
Python
43 lines
989 B
Python
import os
|
|
|
|
from flask import Flask
|
|
|
|
|
|
def create_app(test_config=None):
|
|
# create and configure the app
|
|
app = Flask(__name__, instance_relative_config=True)
|
|
app.config.from_mapping(
|
|
SECRET_KEY='dev',
|
|
DATABASE=os.path.join(app.instance_path, 'database.sqlite'),
|
|
)
|
|
|
|
# ensure the instance folder exists
|
|
os.makedirs(app.instance_path, exist_ok=True)
|
|
|
|
app.config.from_pyfile('config.py')
|
|
|
|
from . import db
|
|
db.init_app(app)
|
|
|
|
from . import auth
|
|
app.register_blueprint(auth.bp)
|
|
|
|
from . import home
|
|
app.register_blueprint(home.bp)
|
|
app.add_url_rule('/', endpoint='index')
|
|
|
|
from . import manage
|
|
app.register_blueprint(manage.bp)
|
|
|
|
from . import blog
|
|
app.register_blueprint(blog.bp)
|
|
|
|
@app.context_processor
|
|
def utility_processor():
|
|
def get_themes():
|
|
themes = os.listdir(app.config["THEMES_FOLDER"])
|
|
return themes
|
|
return dict(get_themes=get_themes)
|
|
|
|
return app
|