Download app.py from KrishnaHuYaar/String-Converter-Mini-App: direct link, hf CLI and curl.
- Browser
- Download file 1.39 kB
-
https://huggingface.co/spaces/KrishnaHuYaar/String-Converter-Mini-App/resolve/main/app.py
- Command line
-
hf download hf://spaces/KrishnaHuYaar/String-Converter-Mini-App/app.py
-
curl -L -o app.py https://huggingface.co/spaces/KrishnaHuYaar/String-Converter-Mini-App/resolve/main/app.py
1.39 kB
| import gradio as gr | |
| def string_converter(text): | |
| if not text: | |
| return "", "", "", "", 0, 0 | |
| uppercase = text.upper() | |
| lowercase = text.lower() | |
| titlecase = text.title() | |
| reversed_text = text[::-1] | |
| char_count = len(text) | |
| word_count = len(text.split()) | |
| return ( | |
| uppercase, | |
| lowercase, | |
| titlecase, | |
| reversed_text, | |
| char_count, | |
| word_count | |
| ) | |
| with gr.Blocks(title="String Converter App") as app: | |
| gr.Markdown("## 🔤 String Converter Mini App") | |
| gr.Markdown("Enter text and get multiple string transformations instantly.") | |
| input_text = gr.Textbox( | |
| label="Input Text", | |
| placeholder="Type your text here...", | |
| lines=3 | |
| ) | |
| convert_btn = gr.Button("Convert") | |
| upper_out = gr.Textbox(label="Uppercase") | |
| lower_out = gr.Textbox(label="Lowercase") | |
| title_out = gr.Textbox(label="Title Case") | |
| reverse_out = gr.Textbox(label="Reversed String") | |
| char_count_out = gr.Number(label="Character Count") | |
| word_count_out = gr.Number(label="Word Count") | |
| convert_btn.click( | |
| fn=string_converter, | |
| inputs=input_text, | |
| outputs=[ | |
| upper_out, | |
| lower_out, | |
| title_out, | |
| reverse_out, | |
| char_count_out, | |
| word_count_out | |
| ] | |
| ) | |
| if __name__ == "__main__": | |
| app.launch() |