File size: 1,497 Bytes
6b3be9d ebe1056 9f12d53 3118555 9f12d53 581122e 3b64a98 9f12d53 25f01a4 ebe1056 70f58dd 581122e ebe1056 581122e d17398d 70f58dd 581122e ebe1056 70f58dd ebe1056 70f58dd 581122e 9f12d53 ebe1056 |
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 |
<!DOCTYPE html>
<html>
<head>
<script type="module" crossorigin src="https://cdn.jsdelivr.net/npm/@gradio/[email protected]/dist/lite.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@gradio/[email protected]/dist/lite.css" />
</head>
<body>
<gradio-lite>
<gradio-requirements>
transformers_js_py
typing-extensions
</gradio-requirements>
import gradio as gr
import random
FORTUNES = [
"A pleasant surprise is waiting for you.",
"Your hard work will pay off in the near future.",
"A new opportunity will present itself soon.",
"Your creativity will lead you to success.",
"An unexpected journey will bring you joy.",
"A wise decision lies ahead of you.",
"Your kindness will be rewarded tenfold.",
"A long-lost friend will reenter your life.",
"Your persistence will overcome current challenges.",
"A positive change is on the horizon."
]
def get_fortune(name):
if not name.strip():
return "Please enter your name to receive a fortune."
fortune = random.choice(FORTUNES)
return f"{name.strip()}, your fortune: {fortune}"
with gr.Blocks() as demo:
gr.Markdown("# 🥠 Fortune Cookie Generator")
name_input = gr.Textbox(label="Your Name")
fortune_output = gr.Textbox(label="Your Fortune")
submit_button = gr.Button("Get Fortune")
submit_button.click(fn=get_fortune, inputs=name_input, outputs=fortune_output)
if __name__ == "__main__":
demo.launch()
</gradio-lite>
</body>
</html> |