| import gradio as gr | |
| # Secret Code Generator (Reverse the input) | |
| def secret_code(input_text): | |
| # Reverse the input text to make it 'secret' | |
| return input_text[::-1] | |
| # Gradio interface | |
| with gr.Blocks() as demo: | |
| input_text = gr.Textbox(label="Enter your text") | |
| output_text = gr.Textbox(label="Secret Code") | |
| # Button to convert to secret code | |
| btn_secret = gr.Button("Convert to Secret Code") | |
| btn_secret.click(secret_code, inputs=input_text, outputs=output_text) | |
| # Button to decode secret code | |
| btn_decode = gr.Button("Decode the Secret Code") | |
| btn_decode.click(secret_code, inputs=output_text, outputs=input_text) | |
| demo.launch() | |