Shouvik599 commited on
Commit Β·
a7bda33
1
Parent(s): 6c174fd
Updated app.py
Browse files
app.py
CHANGED
|
@@ -115,19 +115,26 @@ def ask(request: AskRequest):
|
|
| 115 |
except Exception as e:
|
| 116 |
raise HTTPException(status_code=500, detail=str(e))
|
| 117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
# βββ Entry Point ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 120 |
|
| 121 |
if __name__ == "__main__":
|
| 122 |
import uvicorn
|
| 123 |
|
|
|
|
| 124 |
host = os.getenv("HOST", "0.0.0.0")
|
| 125 |
-
port = int(os.getenv("PORT", "
|
| 126 |
|
| 127 |
print(f"\nποΈ Sacred Texts RAG β API Server")
|
| 128 |
print(f"{'β' * 40}")
|
| 129 |
-
print(f"π Running at : http://
|
| 130 |
-
print(f"π Docs at : http://localhost:{port}/docs")
|
| 131 |
print(f"{'β' * 40}\n")
|
| 132 |
|
| 133 |
-
uvicorn.run("app:app", host=host, port=port, reload=
|
|
|
|
| 115 |
except Exception as e:
|
| 116 |
raise HTTPException(status_code=500, detail=str(e))
|
| 117 |
|
| 118 |
+
@app.get("/", include_in_schema=False)
|
| 119 |
+
async def serve_frontend():
|
| 120 |
+
"""Serves the static frontend HTML file."""
|
| 121 |
+
frontend_path = "frontend/index.html"
|
| 122 |
+
if os.path.exists(frontend_path):
|
| 123 |
+
return FileResponse(frontend_path)
|
| 124 |
+
return {"message": "Sacred Texts RAG API is live. Visit /docs for Swagger UI."}
|
| 125 |
|
| 126 |
# βββ Entry Point ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 127 |
|
| 128 |
if __name__ == "__main__":
|
| 129 |
import uvicorn
|
| 130 |
|
| 131 |
+
# HF Spaces uses 7860 by default
|
| 132 |
host = os.getenv("HOST", "0.0.0.0")
|
| 133 |
+
port = int(os.getenv("PORT", "7860"))
|
| 134 |
|
| 135 |
print(f"\nποΈ Sacred Texts RAG β API Server")
|
| 136 |
print(f"{'β' * 40}")
|
| 137 |
+
print(f"π Running at : http://{host}:{port}")
|
|
|
|
| 138 |
print(f"{'β' * 40}\n")
|
| 139 |
|
| 140 |
+
uvicorn.run("app:app", host=host, port=port, reload=False) # reload=False for production
|