Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -245,33 +245,11 @@ stream = Stream(
|
|
245 |
rtc_configuration=rtc_config # Add the WebRTC configuration
|
246 |
)
|
247 |
|
248 |
-
#
|
249 |
-
|
250 |
-
from fastapi.middleware.cors import CORSMiddleware
|
251 |
-
import gradio as gr
|
252 |
-
|
253 |
-
app = FastAPI()
|
254 |
-
|
255 |
-
# Add CORS middleware
|
256 |
-
app.add_middleware(
|
257 |
-
CORSMiddleware,
|
258 |
-
allow_origins=["*"],
|
259 |
-
allow_credentials=True,
|
260 |
-
allow_methods=["*"],
|
261 |
-
allow_headers=["*"],
|
262 |
-
)
|
263 |
-
|
264 |
-
# Mount the Gradio app
|
265 |
-
app = gr.mount_gradio_app(app, stream.ui, path="/")
|
266 |
-
|
267 |
-
# Add the Stream to FastAPI
|
268 |
-
stream.mount(app)
|
269 |
|
270 |
-
#
|
|
|
|
|
271 |
|
272 |
-
#
|
273 |
-
if __name__ == "__main__" and not os.getenv("HF_SPACE"):
|
274 |
-
import uvicorn
|
275 |
-
PORT = int(os.getenv("PORT", 7860))
|
276 |
-
print(f"Using port: {PORT}")
|
277 |
-
uvicorn.run(app, host="0.0.0.0", port=PORT)
|
|
|
245 |
rtc_configuration=rtc_config # Add the WebRTC configuration
|
246 |
)
|
247 |
|
248 |
+
# Create the Gradio interface without serving it
|
249 |
+
ui = stream.ui
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
|
251 |
+
# Export the Gradio app for Hugging Face Spaces to find it
|
252 |
+
# In Hugging Face Spaces, this will be automatically served
|
253 |
+
demo = ui
|
254 |
|
255 |
+
# Do not include any server initialization code here - just export the Gradio app
|
|
|
|
|
|
|
|
|
|