2026-04-06 15:22:38 -04:00
|
|
|
import logging
|
2026-04-06 14:53:49 -04:00
|
|
|
import os
|
2026-04-06 15:22:38 -04:00
|
|
|
|
2026-04-06 14:53:49 -04:00
|
|
|
from flask import Flask
|
|
|
|
|
from flask_sqlalchemy import SQLAlchemy
|
2026-04-06 15:22:38 -04:00
|
|
|
|
2026-04-06 14:53:49 -04:00
|
|
|
import config
|
|
|
|
|
|
|
|
|
|
db = SQLAlchemy()
|
2026-04-06 15:22:38 -04:00
|
|
|
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(name)s %(levelname)s %(message)s")
|
2026-04-06 14:53:49 -04:00
|
|
|
|
|
|
|
|
|
2026-04-06 15:22:38 -04:00
|
|
|
def create_app(start_scheduler=True):
|
2026-04-06 14:53:49 -04:00
|
|
|
app = Flask(__name__)
|
|
|
|
|
app.config.from_object(config)
|
2026-04-06 15:22:38 -04:00
|
|
|
app.config["SECRET_KEY"] = os.environ.get("SECRET_KEY", os.urandom(24))
|
2026-04-06 14:53:49 -04:00
|
|
|
|
|
|
|
|
os.makedirs(config.DATA_DIR, exist_ok=True)
|
|
|
|
|
os.makedirs(config.IMAGES_DIR, exist_ok=True)
|
|
|
|
|
os.makedirs(config.ISSUES_DIR, exist_ok=True)
|
|
|
|
|
|
|
|
|
|
db.init_app(app)
|
|
|
|
|
|
|
|
|
|
with app.app_context():
|
|
|
|
|
from src import models # noqa: F401
|
|
|
|
|
db.create_all()
|
|
|
|
|
|
2026-04-06 15:22:38 -04:00
|
|
|
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
|
|
|
|
|
|
2026-04-06 14:53:49 -04:00
|
|
|
return app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
app = create_app()
|
2026-04-06 15:22:38 -04:00
|
|
|
app.run(host="0.0.0.0", port=5000, debug=False)
|