fortune / index.html
akhaliq's picture
akhaliq HF staff
Create index.html
ebe1056 verified
raw
history blame
1.38 kB
<html>
<head>
<script type="module" crossorigin src="https://cdn.jsdelivr.net/npm/@gradio/lite/dist/lite.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@gradio/lite/dist/lite.css" />
<style>
body {
font-family: Arial, sans-serif;
background-color: #f7f1e3;
}
</style>
</head>
<body>
<gradio-lite>
import gradio as gr
import random
subjects = ['You', 'Your family', 'Your friends', 'A stranger', 'An opportunity']
verbs = ['will find', 'may encounter', 'should seek', 'will discover', 'might stumble upon']
objects = ['happiness', 'success', 'a challenge', 'love', 'wisdom']
timeframes = ['soon', 'in the near future', 'when you least expect it', 'after overcoming an obstacle', 'as a result of your hard work']
def generate_fortune(name):
fortune = f"{random.choice(subjects)} {random.choice(verbs)} {random.choice(objects)} {random.choice(timeframes)}."
if name:
return f"{name}, {fortune.lower()}"
return fortune
def fortune_cookie(name):
return generate_fortune(name)
iface = gr.Interface(
fn=fortune_cookie,
inputs=gr.Textbox(label="Enter your name (optional)"),
outputs=gr.Textbox(label="Your Fortune"),
title="Fortune Cookie Generator",
description="Get your personalized fortune!",
)
iface.launch()
</gradio-lite>
</body>
</html>