feat: full integration — app.py wiring, scheduler startup, route registration, README
- Wire blueprints and scheduler into create_app() - Add start_scheduler param to skip scheduler in tests - Fix Setting.get/set to use modern db.session.get() - Remove unused imports from conftest and models - Add README with quick start and usage guide Made-with: Cursor
This commit is contained in:
19
app.py
19
app.py
@@ -1,15 +1,19 @@
|
||||
import logging
|
||||
import os
|
||||
|
||||
from flask import Flask
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
|
||||
import config
|
||||
|
||||
db = SQLAlchemy()
|
||||
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(name)s %(levelname)s %(message)s")
|
||||
|
||||
|
||||
def create_app():
|
||||
def create_app(start_scheduler=True):
|
||||
app = Flask(__name__)
|
||||
app.config.from_object(config)
|
||||
app.config["SECRET_KEY"] = os.urandom(24)
|
||||
app.config["SECRET_KEY"] = os.environ.get("SECRET_KEY", os.urandom(24))
|
||||
|
||||
os.makedirs(config.DATA_DIR, exist_ok=True)
|
||||
os.makedirs(config.IMAGES_DIR, exist_ok=True)
|
||||
@@ -21,9 +25,18 @@ def create_app():
|
||||
from src import models # noqa: F401
|
||||
db.create_all()
|
||||
|
||||
from src.routes import register_blueprints
|
||||
register_blueprints(app)
|
||||
|
||||
if start_scheduler:
|
||||
from src.scheduler import SchedulerManager
|
||||
scheduler_mgr = SchedulerManager(app)
|
||||
scheduler_mgr.start()
|
||||
app.config["SCHEDULER_MANAGER"] = scheduler_mgr
|
||||
|
||||
return app
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = create_app()
|
||||
app.run(host="0.0.0.0", port=5000, debug=True)
|
||||
app.run(host="0.0.0.0", port=5000, debug=False)
|
||||
|
||||
Reference in New Issue
Block a user