Pratham0100 commited on
Commit
477bf82
·
verified ·
1 Parent(s): a57d017

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -19
app.py CHANGED
@@ -1,33 +1,22 @@
1
  import sys
2
  import os
3
  import gradio as gr
4
- import spaces
5
- import uvicorn # Add this import
6
 
7
  # Add src to python path so neural_archaeology module is found
8
  sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "src" )))
9
 
10
  from backend.main import app as fastapi_app
11
 
12
- # Dummy GPU function to satisfy ZeroGPU hardware requirements
13
- @spaces.GPU
14
- def fake_gpu_function():
15
- return "BrainBox Backend API is running! Access the frontend to use it."
16
 
17
- # Explicitly invoke the function once during startup to register the ZeroGPU daemon
18
- fake_gpu_function()
19
-
20
- # Dummy Gradio app to satisfy Hugging Face Spaces routing requirements
21
  demo = gr.Interface(
22
- fn=fake_gpu_function,
23
  inputs=[],
24
- outputs= "text",
25
- title= "BrainBox API Core"
26
  )
27
 
28
- # Mount FastAPI inside Gradio!
29
- app = gr.mount_gradio_app(fastapi_app, demo, path= "/" )
30
-
31
- # CRITICAL FIX: Explicitly launch the Uvicorn server to keep the container running
32
- if __name__ == "__main__":
33
- uvicorn.run(app, host="0.0.0.0", port=7860)
 
1
  import sys
2
  import os
3
  import gradio as gr
 
 
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 as fastapi_app
9
 
10
+ def welcome():
11
+ return "BrainBox Backend API is running! Access the /docs endpoint."
 
 
12
 
13
+ # Dummy Gradio app to satisfy Hugging Face Spaces routing
 
 
 
14
  demo = gr.Interface(
15
+ fn=welcome,
16
  inputs=[],
17
+ outputs="text",
18
+ title="BrainBox API Core"
19
  )
20
 
21
+ # Mount FastAPI inside Gradio! Hugging Face automatically detects and runs 'app'
22
+ app = gr.mount_gradio_app(fastapi_app, demo, path="/")