Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
-
import
|
| 2 |
from fastapi import FastAPI
|
| 3 |
from fastapi.middleware.cors import CORSMiddleware
|
| 4 |
-
from backend import
|
| 5 |
from frontend import create_interface
|
| 6 |
-
import
|
| 7 |
|
| 8 |
# Create the main FastAPI app
|
| 9 |
app = FastAPI()
|
|
@@ -18,7 +18,7 @@ app.add_middleware(
|
|
| 18 |
)
|
| 19 |
|
| 20 |
# Include the backend routes
|
| 21 |
-
app.include_router(
|
| 22 |
|
| 23 |
# Create the Gradio interface
|
| 24 |
iface = create_interface()
|
|
@@ -26,6 +26,9 @@ iface = create_interface()
|
|
| 26 |
# Mount the Gradio app
|
| 27 |
app = gr.mount_gradio_app(app, iface, path="/")
|
| 28 |
|
|
|
|
|
|
|
|
|
|
| 29 |
if __name__ == "__main__":
|
| 30 |
-
|
| 31 |
-
uvicorn.run(app, host="0.0.0.0", port=
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
from fastapi import FastAPI
|
| 3 |
from fastapi.middleware.cors import CORSMiddleware
|
| 4 |
+
from backend import router as backend_router
|
| 5 |
from frontend import create_interface
|
| 6 |
+
import os
|
| 7 |
|
| 8 |
# Create the main FastAPI app
|
| 9 |
app = FastAPI()
|
|
|
|
| 18 |
)
|
| 19 |
|
| 20 |
# Include the backend routes
|
| 21 |
+
app.include_router(backend_router)
|
| 22 |
|
| 23 |
# Create the Gradio interface
|
| 24 |
iface = create_interface()
|
|
|
|
| 26 |
# Mount the Gradio app
|
| 27 |
app = gr.mount_gradio_app(app, iface, path="/")
|
| 28 |
|
| 29 |
+
# Hugging Face Spaces provides the port number in the PORT environment variable
|
| 30 |
+
port = int(os.environ.get("PORT", 7860))
|
| 31 |
+
|
| 32 |
if __name__ == "__main__":
|
| 33 |
+
import uvicorn
|
| 34 |
+
uvicorn.run(app, host="0.0.0.0", port=port)
|