ikraamkb commited on
Commit
bf0a429
·
verified ·
1 Parent(s): ab081d8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -3
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
- def hello(name):
 
 
 
 
 
 
 
 
 
82
  return f"Hello, {name}!"
83
 
84
- app = gr.Interface(fn=hello, inputs="text", outputs="text")
 
 
 
 
 
85
 
86
  if __name__ == "__main__":
87
- app.launch()
 
 
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
+