from flask import Flask, render_template, request | |
import gradio as gr | |
app = Flask(__name__) | |
# 定义 Gradio Blocks 示例 | |
def gradio_blocks_demo(): | |
with gr.Blocks() as demo: | |
# 在这里添加您的 Gradio Blocks 组件 | |
gr.Button("Test") | |
return demo | |
# 创建 Gradio Blocks 示例 | |
gradio_demo = gradio_blocks_demo() | |
def home(): | |
# 渲染 HTML 模板,将 Gradio Blocks 示例嵌入到模板中 | |
return render_template('index.html', gradio_demo=gradio_demo) | |
if __name__ == '__main__': | |
gradio_demo.launch() | |