Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import subprocess | |
| import os | |
| UPLOAD_FOLDER = "uploads" | |
| os.makedirs(UPLOAD_FOLDER, exist_ok=True) | |
| def execute_exe(file): | |
| file_path = os.path.join(UPLOAD_FOLDER, file.name) | |
| file.save(file_path) | |
| try: | |
| result = subprocess.run(["bash", "run_exe.sh", file_path], capture_output=True, text=True, timeout=10) | |
| return result.stdout if result.stdout else "No output." | |
| except subprocess.TimeoutExpired: | |
| return "Execution timed out." | |
| with gr.Blocks() as app: | |
| gr.Markdown("### Upload an EXE file to execute") | |
| file_input = gr.File(label="Upload EXE") | |
| output_text = gr.Textbox(label="Execution Output") | |
| file_input.change(execute_exe, file_input, output_text) | |
| app.launch() | |