cli-test-space / app.py
fariasultana's picture
Upload folder using huggingface_hub
2e04129 verified
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)