mirror of
https://github.com/Death916/deathclock.git
synced 2026-04-10 03:04:40 -07:00
weather showing
This commit is contained in:
parent
3bec50f40e
commit
802bcfac6a
3 changed files with 7 additions and 6 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -9,3 +9,4 @@ __pycache__/
|
||||||
chromedriver
|
chromedriver
|
||||||
*.pyc
|
*.pyc
|
||||||
.pyc
|
.pyc
|
||||||
|
*.jpg
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,9 @@ def index() -> rx.Component:
|
||||||
color="white",
|
color="white",
|
||||||
background_color="#6f42c1",
|
background_color="#6f42c1",
|
||||||
),
|
),
|
||||||
rx.box(
|
rx.card(
|
||||||
rx.image(
|
rx.image(
|
||||||
src=Weather().get_weather_screenshot(),
|
src="/weather.jpg", # Use relative path to static asset
|
||||||
alt="Weather",
|
alt="Weather",
|
||||||
width="100%",
|
width="100%",
|
||||||
height="auto",
|
height="auto",
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ class Weather:
|
||||||
# Get the directory where this script (weather.py) is located
|
# Get the directory where this script (weather.py) is located
|
||||||
self.script_dir = os.path.dirname(os.path.abspath(__file__))
|
self.script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
# Construct the absolute path to the 'assets' directory in the same directory as the script
|
# Construct the absolute path to the 'assets' directory in the project root
|
||||||
self.assets_dir = os.path.join(self.script_dir, 'assets')
|
self.assets_dir = os.path.join(os.path.dirname(os.path.dirname(self.script_dir)), 'assets')
|
||||||
|
|
||||||
# Ensure the assets directory exists
|
# Ensure the assets directory exists
|
||||||
if not os.path.exists(self.assets_dir):
|
if not os.path.exists(self.assets_dir):
|
||||||
|
|
@ -30,7 +30,7 @@ class Weather:
|
||||||
try:
|
try:
|
||||||
# Create a timestamp for the filename
|
# Create a timestamp for the filename
|
||||||
timestamp = datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
|
timestamp = datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
|
||||||
screenshot_filename = f"sacramento_weather_{timestamp}.png"
|
screenshot_filename = "weather.png"
|
||||||
screenshot_path = os.path.join(self.assets_dir, screenshot_filename) # save to the proper location
|
screenshot_path = os.path.join(self.assets_dir, screenshot_filename) # save to the proper location
|
||||||
|
|
||||||
# Use curl to get the weather data from wttr.in and save it as a PNG.
|
# Use curl to get the weather data from wttr.in and save it as a PNG.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue