You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.0 KiB
Python

2 years ago
from quart import Quart, redirect, request
2 years ago
from quart_auth import (
AuthManager, Unauthorized
)
from quart_bcrypt import Bcrypt
from lws import config
def create_app():
app = Quart(__name__)
app.config["SECRET_KEY"] = config.SECRET_KEY
2 years ago
app.config["DEBUG"] = config.DEBUG
app.config["TEMPLATES_AUTO_RELOAD"] = config.TEMPLATES_AUTO_RELOAD
2 years ago
app.config["QUART_ENV"] = config.QUART_ENV
app.config["QUART_AUTH_DURATION"] = config.QUART_AUTH_DURATION
app.config["SERVER_NAME"] = config.SERVER_NAME
2 years ago
AuthManager(app)
bcrypt = Bcrypt(app)
@app.before_serving
async def startup():
from lws.routes import auth, wallet, meta
from lws import filters
app.register_blueprint(filters.bp)
app.register_blueprint(auth.bp)
app.register_blueprint(meta.bp)
app.register_blueprint(wallet.bp)
@app.errorhandler(Unauthorized)
async def redirect_to_login(*_):
2 years ago
return redirect(f"/login?next={request.path}")
2 years ago
return app
bcrypt = Bcrypt(create_app())