Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,10 @@
|
|
| 1 |
import uvicorn
|
| 2 |
import gradio as gr
|
| 3 |
import spaces
|
|
|
|
| 4 |
|
| 5 |
# Import your FastAPI app and logic
|
| 6 |
-
from app.main import app as
|
| 7 |
|
| 8 |
@spaces.GPU
|
| 9 |
def _satisfy_zerogpu_startup_check():
|
|
@@ -39,9 +40,16 @@ demo = gr.Interface(
|
|
| 39 |
title="Multilingual Moderation API",
|
| 40 |
)
|
| 41 |
|
| 42 |
-
#
|
| 43 |
-
app =
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
if __name__ == "__main__":
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import uvicorn
|
| 2 |
import gradio as gr
|
| 3 |
import spaces
|
| 4 |
+
from fastapi import FastAPI
|
| 5 |
|
| 6 |
# Import your FastAPI app and logic
|
| 7 |
+
from app.main import app as original_fastapi_app, moderate_text, TextRequest
|
| 8 |
|
| 9 |
@spaces.GPU
|
| 10 |
def _satisfy_zerogpu_startup_check():
|
|
|
|
| 40 |
title="Multilingual Moderation API",
|
| 41 |
)
|
| 42 |
|
| 43 |
+
# ✅ THE FIX: Access Gradio's internal FastAPI app and attach your routes
|
| 44 |
+
app = demo.app
|
| 45 |
|
| 46 |
+
# Re-add your FastAPI routes to the app that Hugging Face is actually serving
|
| 47 |
+
app.include_router(original_fastapi_app.router)
|
| 48 |
+
|
| 49 |
+
# Launch Gradio (this properly initializes @spaces.GPU)
|
| 50 |
if __name__ == "__main__":
|
| 51 |
+
demo.launch(
|
| 52 |
+
server_name="0.0.0.0",
|
| 53 |
+
server_port=7860,
|
| 54 |
+
share=False
|
| 55 |
+
)
|