import quart.flask_patch from quart import Quart from flask_login import LoginManager from flipbook import config async def setup_db(app: Quart): import peewee import flipbook.models models = peewee.Model.__subclasses__() for m in models: m.create_table() def create_app(): app = Quart(__name__) app.config.from_envvar('FLASK_SECRETS') login_manager = LoginManager(app) login_manager.login_view = 'meta.index' login_manager.logout_view = 'meta.logout' @login_manager.user_loader def load_user(user_id): from flipbook.models import Wallet Wallet = Wallet.get(user_id) return Wallet @app.before_serving async def startup(): from flipbook.routes import meta, api, manage from flipbook import filters await setup_db(app) app.register_blueprint(meta.bp) app.register_blueprint(manage.bp) app.register_blueprint(api.bp) app.register_blueprint(filters.bp) # app.register_blueprint(cli.bp) return app