Files
contracts-flask/site/app.py
T
naeel 32660d2590
Deploy contracts-flask / validate (push) Successful in 0s
fix: add app.run() — script was creating app then exiting
2026-07-15 11:46:23 +04:00

46 lines
1.3 KiB
Python

"""contracts-flask v2.0 — полный перенос с ВМ на Flask.
Больше никаких прокси на contracts.kube5s.ru — всё локально.
"""
import sys, os
# site/ в sys.path — импортируем модули напрямую, без префиксов
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from flask import Flask
from config import VERSION, MAX_CONTENT_LENGTH
from routes import register_routes
def create_app():
app = Flask(__name__)
app.config["VERSION"] = VERSION
app.config["MAX_CONTENT_LENGTH"] = MAX_CONTENT_LENGTH
_init_db()
register_routes(app)
@app.after_request
def no_cache(response):
response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
response.headers["Pragma"] = "no-cache"
response.headers["Expires"] = "0"
return response
return app
def _init_db():
"""Создать БД + схему + seed prompts. SQLite — всё в одном файле /tmp."""
from db.connection import init_db
init_db()
try:
from db import prompts as db_prompts
db_prompts.seed_defaults()
except Exception:
pass
app = create_app()
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000, threaded=True)