tarotcard / app.py
openfree's picture
Update app.py
a22942c verified
import gradio as gr
import random
from datetime import datetime
# Complete Tarot Card Dictionary
tarot_cards = {
"โœจ The Fool โœจ": {
"meaning": "New beginnings, innocence, spontaneity",
"description": "๐ŸŒŸ A fresh start awaits! Take that leap of faith with an open heart.",
"image": "fool.jpg"
},
"๐ŸŽฏ The Magician ๐ŸŽฏ": {
"meaning": "Manifestation, resourcefulness, power",
"description": "โšก You have all tools to manifest your desires. Trust your abilities!",
"image": "magician.jpg"
},
"๐Ÿ‘‘ The High Priestess ๐Ÿ‘‘": {
"meaning": "Intuition, mystery, inner wisdom",
"description": "๐ŸŒ™ Listen to your inner voice. Deep wisdom lies within.",
"image": "priestess.jpg"
},
"๐ŸŒบ The Empress ๐ŸŒบ": {
"meaning": "Abundance, nurturing, fertility",
"description": "๐ŸŒธ Embrace your creative power and nurture growth.",
"image": "empress.jpg"
},
"โš”๏ธ The Emperor โš”๏ธ": {
"meaning": "Authority, structure, leadership",
"description": "๐Ÿ‘‘ Time to take charge and establish order.",
"image": "emperor.jpg"
},
"๐Ÿ•Š๏ธ The Hierophant ๐Ÿ•Š๏ธ": {
"meaning": "Tradition, spirituality, guidance",
"description": "๐Ÿ“š Seek wisdom from traditional sources and mentors.",
"image": "hierophant.jpg"
},
"โค๏ธ The Lovers โค๏ธ": {
"meaning": "Love, harmony, relationships",
"description": "๐Ÿ’‘ Important choices about relationships await.",
"image": "lovers.jpg"
},
"๐Ÿƒ The Chariot ๐Ÿƒ": {
"meaning": "Victory, willpower, determination",
"description": "๐ŸŽฏ Success through determination and self-control.",
"image": "chariot.jpg"
},
"๐Ÿฆ Strength ๐Ÿฆ": {
"meaning": "Courage, patience, inner strength",
"description": "๐Ÿ’ช Overcome challenges through inner power.",
"image": "strength.jpg"
},
"๐Ÿฎ The Hermit ๐Ÿฎ": {
"meaning": "Introspection, searching, guidance",
"description": "๐Ÿ” Time for inner reflection and spiritual search.",
"image": "hermit.jpg"
},
"๐ŸŽก Wheel of Fortune ๐ŸŽก": {
"meaning": "Destiny, cycles, turning point",
"description": "๐ŸŒŸ Change is coming. Fortune favors the prepared.",
"image": "wheel.jpg"
},
"โš–๏ธ Justice โš–๏ธ": {
"meaning": "Justice, fairness, truth",
"description": "๐Ÿ“œ Truth and karma will prevail.",
"image": "justice.jpg"
},
"๐Ÿ™ƒ The Hanged Man ๐Ÿ™ƒ": {
"meaning": "Surrender, letting go, new perspective",
"description": "๐ŸŒˆ See things from a different angle.",
"image": "hanged.jpg"
},
"๐Ÿฆ‹ Death ๐Ÿฆ‹": {
"meaning": "Transformation, endings, change",
"description": "๐Ÿ”„ End of one chapter, beginning of another.",
"image": "death.jpg"
},
"๐ŸŒŠ Temperance ๐ŸŒŠ": {
"meaning": "Balance, moderation, harmony",
"description": "โ˜ฏ๏ธ Find middle ground and inner peace.",
"image": "temperance.jpg"
},
"๐Ÿ˜ˆ The Devil ๐Ÿ˜ˆ": {
"meaning": "Bondage, materialism, temptation",
"description": "โ›“๏ธ Break free from what binds you.",
"image": "devil.jpg"
},
"โšก The Tower โšก": {
"meaning": "Sudden change, chaos, revelation",
"description": "๐Ÿ’ฅ Dramatic change leads to breakthrough.",
"image": "tower.jpg"
},
"โญ The Star โญ": {
"meaning": "Hope, inspiration, serenity",
"description": "โœจ Light shines in the darkness.",
"image": "star.jpg"
},
"๐ŸŒ™ The Moon ๐ŸŒ™": {
"meaning": "Illusion, intuition, dreams",
"description": "๐ŸŒŒ Trust your intuition in uncertain times.",
"image": "moon.jpg"
},
"โ˜€๏ธ The Sun โ˜€๏ธ": {
"meaning": "Joy, success, vitality",
"description": "๐ŸŒž Positivity and success shine bright.",
"image": "sun.jpg"
},
"๐Ÿ“ฏ Judgement ๐Ÿ“ฏ": {
"meaning": "Rebirth, inner calling, absolution",
"description": "๐Ÿ”” Answer the call to higher purpose.",
"image": "judgement.jpg"
},
"๐ŸŒ The World ๐ŸŒ": {
"meaning": "Completion, achievement, integration",
"description": "๐ŸŽŠ A cycle completes, bringing fulfillment.",
"image": "world.jpg"
}
}
def get_reading(question, selected_cards):
if not selected_cards:
return "โš ๏ธ Please select at least one card for your reading."
result = f"""
๐Ÿ”ฎ YOUR MYSTICAL TAROT READING ๐Ÿ”ฎ
๐Ÿ’ซ Question: {question}
โœง๏ฝฅ๏พŸ: *โœง๏ฝฅ๏พŸ:* *:๏ฝฅ๏พŸโœง*:๏ฝฅ๏พŸโœง
"""
for i, card in enumerate(selected_cards, 1):
card_info = tarot_cards[card]
result += f"""
โœจ Card {i}: {card}
๐ŸŽด Meaning: {card_info['meaning']}
๐Ÿ“ Message: {card_info['description']}
โˆ˜ยฐโ‰ยฐโˆ˜ยฐโ‰ยฐโˆ˜ยฐโ‰ยฐโˆ˜ยฐโ‰ยฐโˆ˜ยฐโ‰ยฐโˆ˜
"""
return result + "\n\n๐ŸŒŸ May these insights guide your path! ๐ŸŒŸ"
# ... (์ด์ „ tarot_cards ๋”•์…”๋„ˆ๋ฆฌ์™€ get_reading ํ•จ์ˆ˜๋Š” ๋™์ผ)
with gr.Blocks(
theme=gr.themes.Soft(
primary_hue="purple",
secondary_hue="pink",
neutral_hue="slate",
font=["Arial", "sans-serif"]
),
css="""
.gradio-container {
background: linear-gradient(to right, #1a1a2e, #16213e);
color: white;
}
.gr-button {
background: linear-gradient(45deg, #ff6b6b, #ff8e8e);
border: none;
color: white;
}
.gr-input {
border: 2px solid #ff6b6b;
}
.gr-box {
border-radius: 15px;
border: 2px solid #ff6b6b;
}
.gr-padded {
padding: 20px;
}
"""
) as demo:
gr.HTML("""<h1 style='text-align: center'>โœจ Mystical Tarot Reading Experience โœจ</h1>""")
gr.HTML("""
<div style='text-align: center'>
๐ŸŒŸ Welcome to Your Personal Tarot Journey ๐ŸŒŸ<br><br>
๐ŸŽด How to Use:<br>
1. ๐Ÿ’ญ Focus on your question<br>
2. ๐Ÿ” Select 1-5 cards that call to you<br>
3. ๐Ÿ“– Receive your personalized mystical reading<br><br>
๐ŸŒ™ Let the ancient wisdom guide your path ๐ŸŒ™
</div>
""")
with gr.Row():
with gr.Column():
question = gr.Textbox(
label="๐Ÿค” What would you like to know?",
placeholder="Enter your question here...",
lines=3
)
cards = gr.CheckboxGroup(
choices=list(tarot_cards.keys()),
label="๐ŸŽด Select Your Cards (Max 5)",
info="Choose 1-5 cards for your reading"
)
submit_btn = gr.Button("๐Ÿ”ฎ Get Your Reading", variant="primary")
with gr.Column():
output = gr.Textbox(
label="๐Ÿ”ฎ Your Mystical Reading",
lines=20
)
def validate_and_read(question, selected_cards):
if not selected_cards:
return "โš ๏ธ Please select at least one card for your reading."
if len(selected_cards) > 5:
selected_cards = selected_cards[:5]
return get_reading(question, selected_cards)
submit_btn.click(
fn=validate_and_read,
inputs=[question, cards],
outputs=output
)
# Examples
gr.Examples(
examples=[
["What energies surround my current path? ๐Ÿ›ฃ๏ธ", ["โœจ The Fool โœจ", "๐ŸŽฏ The Magician ๐ŸŽฏ"]],
["What should I know about my love life? โค๏ธ", ["โค๏ธ The Lovers โค๏ธ", "๐ŸŒบ The Empress ๐ŸŒบ"]],
["Guide me about my career decisions ๐Ÿ’ผ", ["โš”๏ธ The Emperor โš”๏ธ", "๐ŸŽก Wheel of Fortune ๐ŸŽก"]],
["What's my spiritual lesson for this month? ๐Ÿ™", ["๐Ÿ•Š๏ธ The Hierophant ๐Ÿ•Š๏ธ", "๐Ÿฎ The Hermit ๐Ÿฎ", "โญ The Star โญ"]]
],
inputs=[question, cards]
)
gr.HTML("""
<div style="text-align: center; margin-top: 20px;">
<a href="https://visitorbadge.io/status?path=https%3A%2F%2Fopenfree-tarotcard.hf.space">
<img src="https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fopenfree-tarotcard.hf.space&countColor=%23263759" />
</a>
</div>
""")
if __name__ == "__main__":
demo.launch(share=True)