Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import os | |
| import time | |
| def comfy_mcp_generate(generator_json_file, generator_api_json_file): | |
| return """ | |
| import gradio as gr | |
| import modal | |
| from modal import Image, Stub | |
| import json | |
| def generate_comfy_mcp_app(json_file, api_json_file): | |
| with open(json_file, 'r') as f: | |
| workflow = json.load(f) | |
| with open(api_json_file, 'r') as f: | |
| api_workflow = json.load(f) | |
| # Here you would process the workflow and api_workflow to generate the Gradio app code | |
| # This is a placeholder for the actual logic | |
| gradio_app_code = f""" | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# ComfyUI MCP Generator") | |
| gr.Markdown("This app allows you to process text/images/videos with Comfy MCP and generate a Comfy MCP Gradio app.") | |
| gr.Markdown("## Powered By Modal") | |
| with gr.Row(): | |
| with gr.Column(): | |
| generator_json_file = gr.File(label="Upload Worflow JSON File", file_types=[".json"]) | |
| with gr.Column(): | |
| generator_api_json_file = gr.File(label="Upload Worflow API JSON File", file_types=[".json"]) | |
| with gr.Row(): | |
| with gr.Column(): | |
| generator_output_code = gr.Code(label="Generated (Modal+Gradio) Code", interactive=False) | |
| with gr.Row(): | |
| generator_button = gr.Button("Generate Comfy MCP Gradio App") | |
| generator_button.click( | |
| fn=comfy_mcp_generate, | |
| inputs=[generator_json_file, generator_api_json_file], | |
| outputs=generator_output_code | |
| ) | |
| demo.launch() |