Spaces:
Configuration error
Configuration error
| import gradio as gr | |
| def greet(user_name): | |
| if not user_name: | |
| return "Please enter your name" | |
| return f"Hello {user_name}! π" | |
| def analyze_text(text): | |
| if not text: | |
| return "No text provided" | |
| words = len(text.split()) | |
| chars = len(text) | |
| return f"Words: {words}, Characters: {chars}" | |
| with gr.Blocks(title="cli-test-space") as demo: | |
| gr.Markdown("# cli-test-space\n\nπ A Hugging Face Space!") | |
| with gr.Tab("π Greeting"): | |
| name_input = gr.Textbox(label="Enter your name") | |
| greet_btn = gr.Button("Say Hello") | |
| greet_output = gr.Textbox(label="Greeting") | |
| greet_btn.click(greet, inputs=name_input, outputs=greet_output) | |
| with gr.Tab("π Text Analysis"): | |
| text_input = gr.Textbox(label="Enter text", lines=3) | |
| analyze_btn = gr.Button("Analyze") | |
| text_output = gr.Textbox(label="Analysis") | |
| analyze_btn.click(analyze_text, inputs=text_input, outputs=text_output) | |
| if __name__ == "__main__": | |
| demo.launch(server_name="0.0.0.0", server_port=7860) | |