chatdemo / gradiodemo /Flask /RunGradio.py
tilents
user complete1
869c384
raw
history blame contribute delete
912 Bytes
import gradio as gr
from flask import Flask, render_template
app = Flask(__name__)
def my_function_1(name):
return "dfd"
# 定义多个 Gradio 接口
def gradio_interface_1():
interface = gr.Interface(
fn=my_function_1,
inputs="text",
outputs="text",
)
return interface
def gradio_interface_2():
interface = gr.Interface(
fn=my_function_1,
inputs="image",
outputs="text",
)
return interface
# 创建多个 Gradio 接口
gr_interface_1 = gradio_interface_1()
gr_interface_2 = gradio_interface_2()
# 添加多个 Gradio 接口到 Flask Web 应用程序
@app.route('/')
def home():
return render_template('index.html')
@app.route('/interface1')
def interface1():
return gr_interface_1.launch()
@app.route('/interface2')
def interface2():
return gr_interface_2.launch()
if __name__ == '__main__':
app.run(debug=True)