A. 最终效果

B. 代码实例:
B.1 Gradio
python
import gradio as gr
def greet(name):
return f"你好,{name}!"
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
# demo.launch() # 会输出一个 URL,可用于外部 iframe 嵌入
demo.launch(server_name="0.0.0.0", server_port=7860)
# 192.168.3.69:7860
B.2 Open-WebUI-Function/Pipe
python
from pydantic import BaseModel, Field
class Pipe:
class Valves(BaseModel):
MODEL_ID: str = Field(default="")
def __init__(self):
self.valves = self.Valves()
def pipe(self, body: dict):
html = """
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Gradio Interface</title>
<style>
html, body { margin: 0; height: 100%; }
iframe { width: 100%; height: 100%; border: none; }
</style>
</head>
<body>
<iframe src="http://192.168.3.69:7860"></iframe>
</body>
</html>
C. 注意事项
- ⭐️:要用
ip
地址不要用localhost

D. 思路归档
