[‘weather’][0][‘main’]
import requests
from django.shortcuts import render
def index(request):
appid = ''
url = 'https://api.openweathermap.org/data/2.5/weather?id=2172797{}&units=metric&appid=' + appid
city = 'London'
res = requests.get(url.format(city)).json()
city_info = {
"city": city,
"temp": res['weather'][0]['main'],
"icon": res["weather"]["icon"]
}
context = {'info': city_info}
return render(request, 'weather/index.html', context)