apeHero / start.py
AByGCreation's picture
Refactor code structure for improved readability and maintainability
76c7dab
Raw History Blame Contribute Delete
621 Bytes
"""Entry point with startup diagnostics for Hugging Face Spaces."""
import os
from waitress import serve
from app import app, DB_PATH
if __name__ == "__main__":
port = int(os.environ.get("PORT", "7860"))
print(f"[STARTUP] Flask app loaded; SQLite: {DB_PATH}", flush=True)
print("[STARTUP] Routes:", flush=True)
for rule in sorted(app.url_map.iter_rules(), key=lambda r: r.rule):
print(f"[STARTUP] {rule.rule} {','.join(sorted(rule.methods - {'HEAD','OPTIONS'}))}", flush=True)
print(f"[STARTUP] Listening on 0.0.0.0:{port}", flush=True)
serve(app, host="0.0.0.0", port=port, threads=4)