Spaces:
Sleeping
Sleeping
Create app_gradio.py
Browse files- app_gradio.py +16 -0
app_gradio.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
# Khởi tạo ứng dụng FastAPI
|
| 5 |
+
app = FastAPI()
|
| 6 |
+
|
| 7 |
+
# Hàm xử lý của Gradio
|
| 8 |
+
def greet(name):
|
| 9 |
+
return "Hello " + name + "!"
|
| 10 |
+
|
| 11 |
+
# Tạo giao diện Gradio
|
| 12 |
+
gr_interface = gr.Interface(fn=greet, inputs="text", outputs="text", title="Gradio Space Example")
|
| 13 |
+
|
| 14 |
+
# Gắn Gradio vào FastAPI
|
| 15 |
+
# Endpoint này sẽ được proxy_pass qua Nginx
|
| 16 |
+
app = gr.mount_gradio_app(app, gr_interface, path="/")
|