Pratham0100 commited on
Commit
b6f24fb
·
verified ·
1 Parent(s): 47bd0ff

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +9 -15
app.py CHANGED
@@ -1,23 +1,17 @@
1
  import sys
2
  import os
3
- import gradio as gr
4
 
5
- # Add src to python path so neural_archaeology module is found without pip install -e .
6
  sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "src")))
7
 
8
- from backend.main import app as fastapi_app
 
9
 
 
 
10
  def health_check():
11
- return "BrainBox Backend API is running! Access the frontend to use it."
12
-
13
- # Create a minimal Gradio UI so Hugging Face Spaces recognizes it as a valid Space
14
- demo = gr.Interface(
15
- fn=health_check,
16
- inputs=[],
17
- outputs="text",
18
- title="BrainBox API Core"
19
- )
20
-
21
- # Mount the dummy Gradio app to the root, while preserving all /api/ endpoints
22
- app = gr.mount_gradio_app(fastapi_app, demo, path="/")
23
 
 
 
 
1
  import sys
2
  import os
3
+ import uvicorn
4
 
5
+ # Add src to python path so neural_archaeology module is found
6
  sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "src")))
7
 
8
+ from backend.main import app
9
+ from fastapi.responses import JSONResponse
10
 
11
+ # Hugging Face Spaces healthcheck requires a 200 OK at the root path
12
+ @app.get("/")
13
  def health_check():
14
+ return JSONResponse(content={"status": "running", "message": "BrainBox API is alive"})
 
 
 
 
 
 
 
 
 
 
 
15
 
16
+ if __name__ == "__main__":
17
+ uvicorn.run(app, host="0.0.0.0", port=7860)