Update script.py
This commit is contained in:
parent
5ddb6ca77e
commit
ab1e06bcab
10
script.py
10
script.py
@ -14,7 +14,7 @@ while True:
|
|||||||
# Muuta seuraavat parametrit tarpeen mukaan
|
# Muuta seuraavat parametrit tarpeen mukaan
|
||||||
LATITUDE = "61.4981"
|
LATITUDE = "61.4981"
|
||||||
LONGITUDE = "23.7608"
|
LONGITUDE = "23.7608"
|
||||||
MAX_RESULTS = 15
|
MAX_RESULTS = 8
|
||||||
|
|
||||||
# Lataa maailman kaupunkien tietokanta
|
# Lataa maailman kaupunkien tietokanta
|
||||||
world_cities = pd.read_csv('https://download.geonames.org/export/dump/cities15000.zip', sep='\t', header=None, encoding='utf-8', low_memory=False)
|
world_cities = pd.read_csv('https://download.geonames.org/export/dump/cities15000.zip', sep='\t', header=None, encoding='utf-8', low_memory=False)
|
||||||
@ -41,8 +41,7 @@ while True:
|
|||||||
with open("/var/www/html/index_TEMP.html", "w") as f: # Avaa tiedosto kirjoitustilassa
|
with open("/var/www/html/index_TEMP.html", "w") as f: # Avaa tiedosto kirjoitustilassa
|
||||||
f.write('<meta charset="UTF-8">\n')
|
f.write('<meta charset="UTF-8">\n')
|
||||||
f.write('<meta http-equiv="refresh" content="20">\n')
|
f.write('<meta http-equiv="refresh" content="20">\n')
|
||||||
f.write(f"<h2>Sää tiedot klo:{formatted_time}, {MAX_RESULTS} lähintä kaupunkia tampereelta päin katsottuna..</h2>\n")
|
f.write(f"<h3>Sää tiedot klo:{formatted_time}, {MAX_RESULTS} lähintä kaupunkia.</h3>\n")
|
||||||
f.write(f"<b>Kaupunki, sää, °C, kosteus, paine, tuuli, sade, auringon nousu ja lasku ajat.</b>\n")
|
|
||||||
|
|
||||||
for index, city in nearest_cities.iterrows():
|
for index, city in nearest_cities.iterrows():
|
||||||
if not pd.isnull(city['name']):
|
if not pd.isnull(city['name']):
|
||||||
@ -54,8 +53,6 @@ while True:
|
|||||||
|
|
||||||
# Kirjoita muutaman kaupungin säätiedot tiedostoon
|
# Kirjoita muutaman kaupungin säätiedot tiedostoon
|
||||||
f.write(f"<h3>Muutama kylmä ja kuuma kaupunki</h3>\n")
|
f.write(f"<h3>Muutama kylmä ja kuuma kaupunki</h3>\n")
|
||||||
f.write(f"<b>Kaupunki, sää, °C, kosteus, paine, tuuli, sade, auringon nousu ja lasku.</b>\n")
|
|
||||||
|
|
||||||
for weather_data in weather_data_list:
|
for weather_data in weather_data_list:
|
||||||
f.write(f"<p>{weather_data}</p>\n")
|
f.write(f"<p>{weather_data}</p>\n")
|
||||||
|
|
||||||
@ -63,5 +60,4 @@ while True:
|
|||||||
cmd = 'mv /var/www/html/index_TEMP.html /var/www/html/index.html'
|
cmd = 'mv /var/www/html/index_TEMP.html /var/www/html/index.html'
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
|
|
||||||
time.sleep(120) # Odota 2 minuuttia ennen seuraavaa hakuajoa
|
time.sleep(60) # Odota 1 minuutti ennen seuraavaa hakuajoa
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user