46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
import os
|
|
|
|
from flask import Flask, render_template
|
|
from werkzeug.wsgi import SharedDataMiddleware
|
|
|
|
|
|
def create_app():
|
|
app = Flask(__name__, instance_relative_config=True)
|
|
app.config.from_mapping(
|
|
SQLALCHEMY_DATABASE_URI=os.environ.get("DATABASE_URI"),
|
|
SQLALCHEMY_TRACK_MODIFICATIONS=os.environ.get("TRACK_MODIFICATIONS"),
|
|
SQLALCHEMY_POOL_RECYCLE=os.environ.get("POOL_RECYCLE"),
|
|
USERNAME=os.environ.get("USERNAME"),
|
|
PASSWORD=os.environ.get("PASSWORD"),
|
|
SECRET_KEY=os.environ.get("SECRET_KEY"),
|
|
UPLOAD_FOLDER=os.environ.get("UPLOAD_FOLDER")
|
|
)
|
|
|
|
app.wsgi_app = SharedDataMiddleware(
|
|
app.wsgi_app, {'/uploads': app.config['UPLOAD_FOLDER']})
|
|
|
|
from files.models import db
|
|
db.init_app(app)
|
|
|
|
from files import commands
|
|
commands.init_app(app)
|
|
|
|
from files import auth
|
|
app.register_blueprint(auth.bp)
|
|
|
|
from files import admin
|
|
app.register_blueprint(admin.bp)
|
|
|
|
from files import categories
|
|
app.register_blueprint(categories.bp)
|
|
|
|
from files import about
|
|
app.register_blueprint(about.bp)
|
|
app.add_url_rule('/about', endpoint='about')
|
|
|
|
from files import files
|
|
app.register_blueprint(files.bp)
|
|
app.add_url_rule('/', endpoint='index')
|
|
|
|
return app
|