43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
"""contracts-flask v2.0 — полный перенос с ВМ на Flask.
|
|
Больше никаких прокси на contracts.kube5s.ru — всё локально.
|
|
"""
|
|
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
|
|
|
|
# DB auto-seed — schema migration + seed prompts + crash recovery
|
|
_init_db()
|
|
|
|
# Регистрация всех blueprint'ов
|
|
register_routes(app)
|
|
|
|
# no_cache на все ответы
|
|
@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()
|