Pratham0100 commited on
Commit
20e8798
·
verified ·
1 Parent(s): 11e72b6

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +8 -12
app.py CHANGED
@@ -2,28 +2,24 @@ import sys
2
  import os
3
  import gradio as gr
4
  import spaces
 
5
 
6
- # Add src to python path so neural_archaeology module is found
7
  sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "src")))
8
 
9
  from backend.main import app as fastapi_app
10
 
11
- # Dummy GPU function to satisfy ZeroGPU hardware requirements
12
  @spaces.GPU
13
  def fake_gpu_function():
14
- return "BrainBox Backend API is running! Access the frontend to use it."
15
 
16
- # Dummy Gradio app to satisfy Hugging Face Spaces routing requirements
17
- demo = gr.Interface(
18
- fn=fake_gpu_function,
19
- inputs=[],
20
- outputs="text",
21
- title="BrainBox API Core"
22
- )
23
 
24
- # Mount FastAPI inside Gradio! Hugging Face's runner will automatically launch this.
25
  app = gr.mount_gradio_app(fastapi_app, demo, path="/")
26
 
27
  if __name__ == "__main__":
28
- import uvicorn
29
  uvicorn.run(app, host="0.0.0.0", port=7860)
 
2
  import os
3
  import gradio as gr
4
  import spaces
5
+ import uvicorn
6
 
 
7
  sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "src")))
8
 
9
  from backend.main import app as fastapi_app
10
 
 
11
  @spaces.GPU
12
  def fake_gpu_function():
13
+ return "API is alive!"
14
 
15
+ # Using gr.Blocks guarantees the ZeroGPU AST scanner detects the function!
16
+ with gr.Blocks() as demo:
17
+ gr.Markdown("# BrainBox API is Running")
18
+ btn = gr.Button("Test API")
19
+ out = gr.Textbox()
20
+ btn.click(fn=fake_gpu_function, inputs=[], outputs=out)
 
21
 
 
22
  app = gr.mount_gradio_app(fastapi_app, demo, path="/")
23
 
24
  if __name__ == "__main__":
 
25
  uvicorn.run(app, host="0.0.0.0", port=7860)