Spaces:
Building
Building
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,13 @@
|
|
1 |
-
"""Flare – Minimal backend bootstrap (no UI controllers)
|
2 |
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
3 |
-
Yalnızca sağlık kontrolü, session ve chat endpoint’leri içerir.
|
4 |
-
UI controller’ları tamamlandığında yeniden eklenecek.
|
5 |
-
"""
|
6 |
-
|
7 |
from fastapi import FastAPI
|
|
|
|
|
8 |
import uvicorn
|
|
|
|
|
9 |
|
10 |
from utils import log
|
11 |
from chat_handler import router as chat_router # ← start_session & chat
|
|
|
12 |
|
13 |
app = FastAPI(
|
14 |
title="Flare Orchestration Service",
|
@@ -27,6 +26,28 @@ def health_check():
|
|
27 |
# ---------------- Core chat/session routes --------------------------
|
28 |
app.include_router(chat_router)
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
if __name__ == "__main__":
|
31 |
log("🌐 Starting Flare backend …")
|
32 |
-
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from fastapi import FastAPI
|
2 |
+
from fastapi.staticfiles import StaticFiles
|
3 |
+
from fastapi.responses import FileResponse
|
4 |
import uvicorn
|
5 |
+
import os
|
6 |
+
from pathlib import Path
|
7 |
|
8 |
from utils import log
|
9 |
from chat_handler import router as chat_router # ← start_session & chat
|
10 |
+
from admin_routes import router as admin_router # ← Admin API endpoints
|
11 |
|
12 |
app = FastAPI(
|
13 |
title="Flare Orchestration Service",
|
|
|
26 |
# ---------------- Core chat/session routes --------------------------
|
27 |
app.include_router(chat_router)
|
28 |
|
29 |
+
# ---------------- Admin API routes ----------------------------------
|
30 |
+
app.include_router(admin_router)
|
31 |
+
|
32 |
+
# ---------------- Serve Angular UI if exists ------------------------
|
33 |
+
static_path = Path("static")
|
34 |
+
if static_path.exists() and static_path.is_dir():
|
35 |
+
# Serve static files (Angular assets)
|
36 |
+
app.mount("/assets", StaticFiles(directory="static/assets"), name="assets")
|
37 |
+
|
38 |
+
# Catch-all route for Angular routing (must be last!)
|
39 |
+
@app.get("/{full_path:path}")
|
40 |
+
async def serve_angular(full_path: str):
|
41 |
+
# Don't catch API routes
|
42 |
+
if full_path.startswith("api/") or full_path in ["start_session", "chat"]:
|
43 |
+
return {"error": "Not found"}, 404
|
44 |
+
|
45 |
+
# Return Angular index.html for all other routes
|
46 |
+
index_path = static_path / "index.html"
|
47 |
+
if index_path.exists():
|
48 |
+
return FileResponse(str(index_path))
|
49 |
+
return {"error": "UI not found"}, 404
|
50 |
+
|
51 |
if __name__ == "__main__":
|
52 |
log("🌐 Starting Flare backend …")
|
53 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|