Init Project Flexly CMS
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
"""Фабрика приложения. M0–M1: health и раздача `dist/current` для разработки.
|
||||
|
||||
Дальше: `POST /forms/{id}` и outbox (M2), админка `web/admin/` (M2–M3), превью по токену
|
||||
`/_preview/<token>/` (M1), MCP на `/mcp/` (M3). В production статику отдаёт nginx.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def create_app():
|
||||
from fastapi import FastAPI, HTTPException
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
||||
app = FastAPI(title="Site Engine")
|
||||
dist = Path(os.environ.get("SITE_DIST", "dist"))
|
||||
|
||||
@app.get("/healthz")
|
||||
def healthz() -> dict:
|
||||
return {"status": "ok"}
|
||||
|
||||
@app.post("/forms/{form_id}")
|
||||
def submit_form(form_id: str) -> None:
|
||||
raise HTTPException(status_code=501, detail="приём заявок появится в M2 (ADR-003)")
|
||||
|
||||
if (dist / "current").exists():
|
||||
app.mount("/", StaticFiles(directory=dist / "current", html=True), name="site")
|
||||
return app
|
||||
Reference in New Issue
Block a user