Spaces:
Runtime error

DanudeAi / app.py
DunaevStudio's picture
Update app.py
c5a495e verified
Raw History Blame Contribute Delete
815 Bytes
import os
from fastapi import FastAPI
from fastapi.responses import HTMLResponse
from fastapi.middleware.cors import CORSMiddleware
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/", response_class=HTMLResponse)
async def index():
try:
with open("index.html", "r", encoding="utf-8") as f:
return HTMLResponse(content=f.read())
except FileNotFoundError:
return HTMLResponse(content="<h1>index.html not found</h1>", status_code=404)
@app.get("/health")
async def health():
return {"status": "ok", "service": "DanudeAi Frontend"}
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=int(os.getenv("PORT", "7860")))