Klim Mikhailov
commited on
Commit
·
b3b9782
1
Parent(s):
0bee8f7
working app
Browse files- README.md +12 -29
- app.py +4 -20
- requirements.txt +0 -1
README.md
CHANGED
|
@@ -1,21 +1,21 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
|
| 5 |
-
|
| 6 |
-
- Select a zodiac sign (aries, taurus, gemini, cancer, leo, virgo, libra, scorpio, sagittarius, capricorn, aquarius, pisces)
|
| 7 |
-
- Pick any date using an interactive calendar date picker
|
| 8 |
-
- Real horoscope data from the Beandev Aistrology API in English
|
| 9 |
-
- Comprehensive logging for debugging and monitoring
|
| 10 |
-
- Horoscope-themed UI with gradient background
|
| 11 |
|
| 12 |
-
Usage
|
| 13 |
|
| 14 |
-
1. Install dependencies
|
| 15 |
|
| 16 |
```
|
| 17 |
-
python -m venv .venv
|
| 18 |
-
.venv\Scripts\activate
|
| 19 |
pip install -r requirements.txt
|
| 20 |
```
|
| 21 |
|
|
@@ -29,23 +29,6 @@ python app.py
|
|
| 29 |
|
| 30 |
4. Select your zodiac sign and choose a date from the calendar, then click "Get Horoscope" to receive your personalized horoscope!
|
| 31 |
|
| 32 |
-
How It Works
|
| 33 |
-
|
| 34 |
-
- The app uses the Python `requests` library to fetch real horoscope data in English
|
| 35 |
-
- Connects to the free Beandev Aistrology API (https://api.aistrology.beandev.xyz/v1)
|
| 36 |
-
- Users select any date via an interactive calendar picker (Gradio DateTime component)
|
| 37 |
-
- The selected date is sent to the API in YYYY-MM-DD format using the `date` parameter
|
| 38 |
-
- If the API is unavailable (no internet or API down), displays a clear error message
|
| 39 |
-
- All horoscopes are displayed in English with sections for mood, compatibility, lucky numbers, colors, and more
|
| 40 |
-
- Comprehensive logging tracks all API calls, successes, and errors
|
| 41 |
-
|
| 42 |
-
Customization
|
| 43 |
-
|
| 44 |
-
- Edit `app.py` to change styling or output format
|
| 45 |
-
- The CSS styling contains the gradient background and UI theme
|
| 46 |
-
- You can modify the response formatting section to customize how API results are displayed
|
| 47 |
-
- Adjust logging level in the `logging.basicConfig()` call (INFO, DEBUG, WARNING, ERROR)
|
| 48 |
-
|
| 49 |
API Credits
|
| 50 |
|
| 51 |
- Real horoscope data provided by [Beandev Aistrology API](https://aistrology.beandev.xyz/docs) (free and open source)
|
|
|
|
| 1 |
+
title: Zodiac-AI
|
| 2 |
+
emoji: ✨
|
| 3 |
+
colorFrom: blue
|
| 4 |
+
colorTo: blue
|
| 5 |
+
sdk: gradio
|
| 6 |
+
sdk_version: 5.26.0
|
| 7 |
+
app_file: app.py
|
| 8 |
+
pinned: false
|
| 9 |
|
| 10 |
+
# Horoscope — Zodiac Insights (Gradio)
|
| 11 |
|
| 12 |
+
This is a Gradio web app that provides astrological horoscope predictions and insights for the 12 zodiac signs.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
## Usage
|
| 15 |
|
| 16 |
+
1. Install dependencies:
|
| 17 |
|
| 18 |
```
|
|
|
|
|
|
|
| 19 |
pip install -r requirements.txt
|
| 20 |
```
|
| 21 |
|
|
|
|
| 29 |
|
| 30 |
4. Select your zodiac sign and choose a date from the calendar, then click "Get Horoscope" to receive your personalized horoscope!
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
API Credits
|
| 33 |
|
| 34 |
- Real horoscope data provided by [Beandev Aistrology API](https://aistrology.beandev.xyz/docs) (free and open source)
|
app.py
CHANGED
|
@@ -317,19 +317,10 @@ def build_interface():
|
|
| 317 |
"""
|
| 318 |
from datetime import datetime
|
| 319 |
|
| 320 |
-
#
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
if os.path.exists(bg_path):
|
| 325 |
-
with open(bg_path, "rb") as img_file:
|
| 326 |
-
bg_base64 = base64.b64encode(img_file.read()).decode()
|
| 327 |
-
bg_image_data = f"data:image/jpeg;base64,{bg_base64}"
|
| 328 |
-
logger.info(f"Background image loaded successfully from {bg_path}")
|
| 329 |
-
else:
|
| 330 |
-
logger.warning(f"Background image not found at {bg_path}")
|
| 331 |
-
except Exception as e:
|
| 332 |
-
logger.error(f"Failed to load background image: {e}")
|
| 333 |
|
| 334 |
# Generate CSS with background image
|
| 335 |
CSS = CSS_TEMPLATE.replace('{{BACKGROUND_IMAGE}}', bg_image_data)
|
|
@@ -385,13 +376,6 @@ def build_interface():
|
|
| 385 |
label='Your Horoscope',
|
| 386 |
value=""
|
| 387 |
)
|
| 388 |
-
|
| 389 |
-
# Footer
|
| 390 |
-
gr.HTML("""
|
| 391 |
-
<div style='text-align: center; margin-top: 30px; padding: 20px; color: #8888aa; font-size: 0.9em;'>
|
| 392 |
-
<p>Powered by Beandev Aistrology API • Embrace the wisdom of the cosmos</p>
|
| 393 |
-
</div>
|
| 394 |
-
""")
|
| 395 |
|
| 396 |
def on_get(s, d):
|
| 397 |
s_norm = s.lower()
|
|
|
|
| 317 |
"""
|
| 318 |
from datetime import datetime
|
| 319 |
|
| 320 |
+
# Use a remote background image URL instead of a tracked local file
|
| 321 |
+
# (keeps repository small and avoids storing binaries in git)
|
| 322 |
+
bg_image_data = "https://astrogyanvi.com/uploads/blog/1719644082-blog_image.png"
|
| 323 |
+
logger.info("Using remote background image URL for CSS background")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 324 |
|
| 325 |
# Generate CSS with background image
|
| 326 |
CSS = CSS_TEMPLATE.replace('{{BACKGROUND_IMAGE}}', bg_image_data)
|
|
|
|
| 376 |
label='Your Horoscope',
|
| 377 |
value=""
|
| 378 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 379 |
|
| 380 |
def on_get(s, d):
|
| 381 |
s_norm = s.lower()
|
requirements.txt
CHANGED
|
@@ -1,3 +1,2 @@
|
|
| 1 |
gradio>=6.0
|
| 2 |
requests>=2.25.0
|
| 3 |
-
huggingface_hub>=1.1.5
|
|
|
|
| 1 |
gradio>=6.0
|
| 2 |
requests>=2.25.0
|
|
|