Spaces:
Running on Zero
Running on Zero
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -1,11 +1,23 @@
|
|
| 1 |
import sys
|
| 2 |
import os
|
| 3 |
-
import
|
| 4 |
|
|
|
|
| 5 |
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "src")))
|
| 6 |
|
| 7 |
-
from backend.main import app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
if __name__ == "__main__":
|
| 10 |
-
# Hugging Face Spaces exposes port 7860
|
| 11 |
-
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 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 |
|
|
|
|
|
|
|
|
|