File size: 442 Bytes
f0018cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from fastapi import FastAPI
import gradio as gr

# Khởi tạo ứng dụng FastAPI
app = FastAPI()

# Hàm xử lý của Gradio
def greet(name):
    return "Hello " + name + "!"

# Tạo giao diện Gradio
gr_interface = gr.Interface(fn=greet, inputs="text", outputs="text", title="Gradio Space Example")

# Gắn Gradio vào FastAPI
# Endpoint này sẽ được proxy_pass qua Nginx
app = gr.mount_gradio_app(app, gr_interface, path="/")