Wethaerapi
Wethaerapi
Key Concepts:
• URL routing
• Views
• Templates
• Using a weather API
View Example:
import requests
def current_weather(request):
response = requests.get('http://api.weatherapi.com/v1/
current.json?key=YOUR_API_KEY&q=London')
weather_data = response.json()
temperature = weather_data['current']['temp_c']
condition = weather_data['current']['condition']['text']
return render(request, 'timeapp/current_weather.html',
{'temperature': temperature, 'condition': condition})
HTML Template: