Manishh-07's picture
Update app.py
0329732 verified
import gradio as gr
import subprocess
import os
def run_workflow():
try:
print("πŸ“Œ Checking if hr.py exists...")
script_path = "ComfyUI/hr.py"
if not os.path.exists(script_path):
print("❌ Error: hr.py not found!")
return "Error: hr.py not found!"
print("βœ… Running hr.py...")
result = subprocess.run(["python", script_path], capture_output=True, text=True)
if result.returncode == 0:
print("βœ… Execution Successful!")
return result.stdout
else:
print(f"❌ Execution Failed:\n{result.stderr}")
return f"Error:\n{result.stderr}"
except Exception as e:
print(f"❌ Exception: {str(e)}")
return f"Exception: {str(e)}"
ui = gr.Interface(
fn=run_workflow,
inputs=[],
outputs="text",
title="Run ComfyUI Workflow",
description="Click the button to execute hr.py and generate an image."
)
print("πŸš€ Launching Gradio UI...")
if __name__ == "__main__":
ui.launch(share=True)