Repository navigation
Expand file tree
/
Copy pathapp.py
More file actions
50 lines (35 loc) · 1.37 KB
/
Copy pathapp.py
File metadata and controls
50 lines (35 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from dotenv import load_dotenv
from pathlib import Path
# Must be first — before any module that reads env vars
from fastapi import FastAPI
from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles
from database import engine
import models
from routes.auth_routes import router as auth_router
from routes.chat_routes import router as chat_router
from fastapi.responses import JSONResponse
load_dotenv(dotenv_path=Path(__file__).parent / ".env", override=True)
# Auto-create all tables on startup (like php artisan migrate)
models.Base.metadata.create_all(bind=engine)
app = FastAPI(title="AI Chat")
@app.get("/.well-known/appspecific/com.chrome.devtools.json")
async def chrome_devtools():
return JSONResponse(content={})
@app.get("/", response_class=HTMLResponse)
def index():
with open("static/index.html", encoding="utf-8") as f:
return f.read()
app.mount("/static", StaticFiles(directory="static"), name="static")
app.include_router(auth_router)
app.include_router(chat_router)
@app.get("/api/info")
def get_info():
import os
model_name = os.getenv("GEMINI_MODEL") or os.getenv("OPENAI_API_MODEL") or "gemini-2.5-flash"
model_name = model_name.strip('"\'')
formatted = model_name.replace("-", " ").replace("_", " ").title()
return {"model": formatted}
@app.get("/health")
def health():
return {"status": "ok"}