File size: 513 Bytes
f673293
 
0c3bf97
 
 
 
f673293
 
0c3bf97
 
 
 
 
f673293
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import gradio as gr

def to_print_line(text):
    # Escape double quotes inside the text
    escaped_text = text.replace('"', '\\"')
    return f'print("{escaped_text}")'

interface = gr.Interface(
    fn=to_print_line,
    inputs=gr.Textbox(lines=2, label="Text to print"),
    outputs=gr.Textbox(lines=2, label="Generated Python Code"),
    title="🖨️ Simple Python Code Generator",
    description="Turns your input text into a Python print statement."
)

if __name__ == "__main__":
    interface.launch()