File size: 671 Bytes
0f24bef
 
 
 
 
 
 
 
 
 
d8ef852
51b9ec2
d8ef852
0f24bef
 
 
877359c
0f24bef
 
 
 
 
 
 
 
de69790
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import gradio as gr
import sys

def execute_code(code):
    try:
        exec(code, globals())
        return "Code executed successfully!"
    except Exception as e:
        return f"Error: {str(e)}"

code_input = gr.Textbox(lines=10, label="Enter Python code")
execute_button = gr.Button()
result_text = gr.Textbox(label="Execution Result")

def execute_code_callback(code):
    return execute_code(code)
print("hello")
iface = gr.Interface(
    fn=execute_code_callback,
    inputs=[code_input, execute_button],
    outputs=result_text,
    title="Code Executor",
    description="Enter your Python code and click 'Execute Code' to run it."
)

iface.launch(share=True)