Uncategorized

python gradio 笔记-CSDN博客


def main():
    global tmpdir

    with gr.Blocks() as demo:
        with gr.Row():
            with tempfile.TemporaryDirectory(dir='./tmp/') as tmpdir:
                # 定义输入和输出
                inputs = gr.components.File(label="上传文件", file_types=["xlsx"])
                outputs = gr.components.File(label="下载文件", file_types=["xlsx"])
        with gr.Row():
            gen_button = gr.Button("计算体侧成绩")
        with gr.Row():
            with gr.Accordion("demo案例"):
                gr.Markdown("<div align='center'> <a href='https://pan.quark.cn/s/16b6619ea924'> 下载demo文件 </a>  </div>")



        gen_button.click(generate_file, inputs=inputs, outputs=outputs)


        # 启动应用程序
        demo.launch(share=True)


if __name__ == "__main__":
    main()

graido 布局

从零开始的AGI开发:Gradio入门指南 – 知乎

文件上传,下载

使用gradio库的File模块实现文件上传和生成可下载文件_gradio 文件下载-CSDN博客

官方文档

Quickstart



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *