Version 1.0.3: Verbesserte Adressanzeige mit Location-Icon
This commit is contained in:
38
app.py
38
app.py
@@ -3,16 +3,17 @@ import pandas as pd
|
||||
import os
|
||||
import logging
|
||||
import numpy as np
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timedelta
|
||||
from dotenv import load_dotenv
|
||||
import requests
|
||||
from collections import defaultdict
|
||||
|
||||
app = Flask(__name__, static_folder='static')
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Version der Anwendung
|
||||
VERSION = "1.0.2"
|
||||
VERSION = "1.0.3"
|
||||
|
||||
# Pfad zur CSV-Datei
|
||||
CSV_FILE = "data/customers.csv"
|
||||
@@ -47,31 +48,6 @@ def load_data():
|
||||
logger.error(f"Fehler beim Laden der CSV-Datei: {str(e)}")
|
||||
return None
|
||||
|
||||
def get_weather(city):
|
||||
"""Holt Wetterinformationen für eine Stadt von der OpenWeather API"""
|
||||
api_key = os.getenv('OPENWEATHER_API_KEY')
|
||||
base_url = "http://api.openweathermap.org/data/2.5/weather"
|
||||
|
||||
try:
|
||||
params = {
|
||||
'q': city,
|
||||
'appid': api_key,
|
||||
'units': 'metric', # Temperatur in Celsius
|
||||
'lang': 'de'
|
||||
}
|
||||
response = requests.get(base_url, params=params)
|
||||
data = response.json()
|
||||
|
||||
if response.status_code == 200:
|
||||
return {
|
||||
'temperature': round(data['main']['temp']),
|
||||
'icon': data['weather'][0]['icon'],
|
||||
'description': data['weather'][0]['description']
|
||||
}
|
||||
except Exception as e:
|
||||
logger.error(f"Fehler beim Abrufen der Wetterdaten: {e}")
|
||||
return None
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return render_template('index.html')
|
||||
@@ -133,14 +109,6 @@ def search():
|
||||
results = df[mask].to_dict('records')
|
||||
logger.info(f"{len(results)} Ergebnisse gefunden")
|
||||
|
||||
# Füge Wetterinformationen für jeden Treffer hinzu
|
||||
for result in results:
|
||||
weather = get_weather(result['Ort'])
|
||||
if weather:
|
||||
result['weather'] = weather
|
||||
else:
|
||||
result['weather'] = None
|
||||
|
||||
return jsonify({
|
||||
'results': results,
|
||||
'total': len(results)
|
||||
|
Reference in New Issue
Block a user