Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -76,12 +76,29 @@ async def visualize(
|
|
76 |
|
77 |
|
78 |
return StreamingResponse(img_stream, media_type="image/png")'''
|
|
|
79 |
import gradio as gr
|
|
|
80 |
|
81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
return f"Hello, {name}!"
|
83 |
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
if __name__ == "__main__":
|
87 |
-
app.
|
|
|
|
76 |
|
77 |
|
78 |
return StreamingResponse(img_stream, media_type="image/png")'''
|
79 |
+
from fastapi import FastAPI
|
80 |
import gradio as gr
|
81 |
+
import uvicorn
|
82 |
|
83 |
+
# FastAPI instance
|
84 |
+
app = FastAPI()
|
85 |
+
|
86 |
+
# Example FastAPI route
|
87 |
+
@app.get("/")
|
88 |
+
def read_root():
|
89 |
+
return {"message": "Welcome to FastAPI & Gradio App!"}
|
90 |
+
|
91 |
+
# Gradio Interface
|
92 |
+
def greet(name):
|
93 |
return f"Hello, {name}!"
|
94 |
|
95 |
+
gradio_app = gr.Interface(fn=greet, inputs="text", outputs="text")
|
96 |
+
|
97 |
+
# Mount Gradio inside FastAPI
|
98 |
+
@app.get("/gradio")
|
99 |
+
def gradio_ui():
|
100 |
+
return gradio_app.launch(share=False, inline=True)
|
101 |
|
102 |
if __name__ == "__main__":
|
103 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|
104 |
+
|