wanderhome-quiz/server/app/__init__.py

28 lines
675 B
Python
Raw Permalink Normal View History

2022-08-24 15:55:53 +01:00
from .config import Development as Config
from .models import *
2022-08-31 00:48:36 +01:00
from .extensions import cors, db
2022-08-24 15:55:53 +01:00
from flask import Flask
from werkzeug.middleware.proxy_fix import ProxyFix
def create_app():
app = Flask(__name__)
app.config.from_object(Config())
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto = 1, x_host = 1)
2022-08-31 00:48:36 +01:00
cors.init_app(app=app)
2022-08-24 15:55:53 +01:00
db.init_app(app=app)
from .views import views
app.register_blueprint(
blueprint = views,
url_prefix = '/api'
)
"""Create database before first request"""
@app.before_first_request
def _create_database_tables():
with app.app_context(): db.create_all()
return app