Spaces:
Sleeping
Sleeping
File size: 1,938 Bytes
5f2a1ff fa7fde3 5f2a1ff 3d1ab31 86df3fc 48f799b 86df3fc 5f2a1ff 86df3fc 3d1ab31 751c5bd 48f799b 751c5bd 86df3fc fa7fde3 86df3fc fa7fde3 86df3fc fa7fde3 751c5bd 48f799b 751c5bd fa7fde3 86df3fc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | import gradio as gr
from datetime import datetime
def greet(name):
if not name:
return "Please enter your name!"
return f"Hello {name}! Welcome to the updated HF Sync Test Space! πβ¨"
def reverse_text(text):
return text[::-1] if text else ""
def shake_it(text):
if not text:
return "Give me something to shake!"
return " ".join(reversed(text.split()))
# Create a tabbed interface with multiple functions
with gr.Blocks(title="HF Sync Test - Updated!") as demo:
gr.Markdown("# π Hugging Face Sync Test")
gr.Markdown("### Testing automatic sync from GitHub β HF Space")
with gr.Tab("Greeting"):
name_input = gr.Textbox(label="Enter your name", placeholder="Claude")
greet_output = gr.Textbox(label="Greeting")
greet_btn = gr.Button("Greet Me!")
greet_btn.click(greet, inputs=name_input, outputs=greet_output)
with gr.Tab("Text Reverser"):
text_input = gr.Textbox(label="Enter text to reverse", placeholder="Hello World")
reverse_output = gr.Textbox(label="Reversed text")
reverse_btn = gr.Button("Reverse!")
reverse_btn.click(reverse_text, inputs=text_input, outputs=reverse_output)
# Shake words around β reverses word order instead of characters
with gr.Tab("Word Shaker"):
shake_input = gr.Textbox(label="Enter a sentence", placeholder="The sync is working great")
shake_output = gr.Textbox(label="Shaken words")
shake_btn = gr.Button("Shake it!")
shake_btn.click(shake_it, inputs=shake_input, outputs=shake_output)
# Tab to confirm sync worked
with gr.Tab("Sync Check"):
gr.Markdown(f"β
Synced at: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')} UTC")
gr.Markdown("If you see this tab, the sync is working!")
gr.Markdown("---")
gr.Markdown("*This Space is auto-synced from GitHub using huggingface-sync-action*")
demo.launch() |