Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,6 +8,8 @@ import numpy as np
|
|
| 8 |
from fastapi import FastAPI
|
| 9 |
from fastapi.responses import FileResponse
|
| 10 |
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
|
|
|
| 11 |
|
| 12 |
# Create a FastAPI app instance for API calls
|
| 13 |
app = FastAPI()
|
|
@@ -103,7 +105,13 @@ def create_gradio_interface():
|
|
| 103 |
gr.HTML(custom_css) # Embed the custom CSS
|
| 104 |
interface.render()
|
| 105 |
|
| 106 |
-
demo.launch(share=True, server_name="0.0.0.0", server_port=
|
| 107 |
|
| 108 |
-
#
|
| 109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
from fastapi import FastAPI
|
| 9 |
from fastapi.responses import FileResponse
|
| 10 |
from fastapi.middleware.cors import CORSMiddleware
|
| 11 |
+
import threading
|
| 12 |
+
import uvicorn
|
| 13 |
|
| 14 |
# Create a FastAPI app instance for API calls
|
| 15 |
app = FastAPI()
|
|
|
|
| 105 |
gr.HTML(custom_css) # Embed the custom CSS
|
| 106 |
interface.render()
|
| 107 |
|
| 108 |
+
demo.launch(share=True, server_name="0.0.0.0", server_port=7861)
|
| 109 |
|
| 110 |
+
# Function to run FastAPI in a separate thread
|
| 111 |
+
def run_fastapi():
|
| 112 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|
| 113 |
+
|
| 114 |
+
# Run FastAPI and Gradio interfaces
|
| 115 |
+
if __name__ == "__main__":
|
| 116 |
+
threading.Thread(target=run_fastapi).start()
|
| 117 |
+
create_gradio_interface()
|