45 lines
1.0 KiB
Python
45 lines
1.0 KiB
Python
import os
|
|
|
|
from flask import Flask, render_template
|
|
from werkzeug import SharedDataMiddleware
|
|
|
|
def create_app():
|
|
app = Flask(__name__, instance_relative_config=True)
|
|
|
|
app.config.from_mapping(
|
|
DATABASE = os.path.join(app.instance_path, 'files.sqlite'),
|
|
USERNAME = 'dev',
|
|
PASSWORD = 'secret',
|
|
SECRET_KEY = '1337',
|
|
UPLOAD_FOLDER = 'uploads',
|
|
ALLOWED_EXTENSIONS = set(['png', 'jpg'])
|
|
)
|
|
|
|
app.config.from_pyfile('config.py')
|
|
app.wsgi_app = SharedDataMiddleware(app.wsgi_app, { '/uploads': app.config['UPLOAD_FOLDER'] })
|
|
|
|
try:
|
|
os.makedirs(app.instance_path)
|
|
except OSError:
|
|
pass
|
|
|
|
from . import db
|
|
db.init_app(app)
|
|
|
|
from . import auth
|
|
app.register_blueprint(auth.bp)
|
|
|
|
from . import categories
|
|
app.register_blueprint(categories.bp)
|
|
|
|
from . import about
|
|
app.register_blueprint(about.bp)
|
|
app.add_url_rule('/about', endpoint='about')
|
|
|
|
from . import files
|
|
app.register_blueprint(files.bp)
|
|
app.add_url_rule('/', endpoint='index')
|
|
|
|
|
|
return app
|