Shouvik599 commited on
Commit
a7bda33
Β·
1 Parent(s): 6c174fd

Updated app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
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", "8000"))
126
 
127
  print(f"\nπŸ•ŠοΈ Sacred Texts RAG β€” API Server")
128
  print(f"{'─' * 40}")
129
- print(f"🌐 Running at : http://localhost:{port}")
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=True)
 
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