modified: app.py
This commit is contained in:
16
app.py
16
app.py
@@ -29,13 +29,13 @@ def get_weather_data():
|
||||
|
||||
# Funktion, um die Wetterdaten für eine bestimmte Station oder einen Ort zu finden
|
||||
def find_weather_by_city(city, geojson_data):
|
||||
city = city.lower().strip() # Benutzereingabe bereinigen
|
||||
|
||||
city = city.strip().lower() # Trimmen und in Kleinbuchstaben umwandeln
|
||||
|
||||
for feature in geojson_data['features']:
|
||||
station_name = feature['properties']['data_004']['value'].strip() # 'STATION OR SITE NAME'
|
||||
station_name = feature['properties']['data_004']['value'].strip().lower() # Station-Name trimm und in Kleinbuchstaben umwandeln
|
||||
|
||||
# Bereinigen des Stationsnamens und Vergleich mit der Eingabe
|
||||
if city in station_name.lower():
|
||||
# Vergleiche den Stadt-/Stationsnamen
|
||||
if city in station_name:
|
||||
return {
|
||||
"station": station_name,
|
||||
"temperature": feature['properties'].get('data_015', {}).get('value', 'Keine Daten'),
|
||||
@@ -44,12 +44,6 @@ def find_weather_by_city(city, geojson_data):
|
||||
"precipitation": feature['properties'].get('data_026', {}).get('value', 'Keine Daten'),
|
||||
"pressure": feature['properties'].get('data_043', {}).get('value', 'Keine Daten'),
|
||||
}
|
||||
|
||||
# Debugging: Gebe die Stationsnamen aus, die durchsucht wurden
|
||||
print(f"Ort nicht gefunden: {city}")
|
||||
for feature in geojson_data['features']:
|
||||
print(f"Verfügbare Station: {feature['properties']['data_004']['value'].strip()}")
|
||||
|
||||
return {"error": "Ort nicht gefunden"}
|
||||
|
||||
# Route zum Laden der Startseite (index.html)
|
||||
|
||||
Reference in New Issue
Block a user