37 lines
899 B
Python
37 lines
899 B
Python
from flask import Flask, request
|
|
|
|
from .config import Config
|
|
from .db import db
|
|
from .models import init_schedule_config
|
|
from .models import ActivityLog, ActivityCategory
|
|
from .blueprints import register_blueprints
|
|
|
|
def create_app(test_config=None):
|
|
app = Flask(__name__)
|
|
app.config.from_object(Config)
|
|
|
|
if test_config:
|
|
app.config.update(test_config)
|
|
|
|
db.init_app(app)
|
|
|
|
with app.app_context():
|
|
db.create_all()
|
|
init_schedule_config()
|
|
|
|
@app.context_processor
|
|
def inject_app_title():
|
|
return {"app_title": app.config["APP_TITLE"]}
|
|
|
|
register_blueprints(app)
|
|
|
|
@app.before_request
|
|
def before_request():
|
|
ActivityLog.log_gui_interaction(
|
|
action=request.endpoint,
|
|
description=f"Request to {request.endpoint}",
|
|
extra={"method": request.method, "url": request.url}
|
|
)
|
|
|
|
return app
|