Делаю web-приложение на django. Приложение погоды. Все погоду берет с этого сайта -
openweathermap.org. После подключения requests появилась ошибка:
ProxyError at /
HTTPSConnectionPool(host='api.openweathermap.org', port=443): Max retries exceeded with url: /data/2.5/weather?q=London&appid=cbf515c1138c3671ac09ee0b4b8e8da0 (Caused by ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory')))
"No such file or directory" что за файл отсутствует?
Вот что пишет терминал:
Traceback (most recent call last):
File "C:\django-sites\trydj\venv\lib\site-packages\requests\adapters.py", line 489, in send
resp = conn.urlopen(
File "C:\django-sites\trydj\venv\lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen
retries = retries.increment(
File "C:\django-sites\trydj\venv\lib\site-packages\urllib3\util\retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.openweathermap.org', port=443): Max retries exceeded with url: /data/2.5/weather?q=London&appid=cbf515c1
138c3671ac09ee0b4b8e8da0 (Caused by ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory')))
requests.exceptions.ProxyError: HTTPSConnectionPool(host='api.openweathermap.org', port=443): Max retries exceeded with url: /data/2.5/weather?q=London&appid=cbf515c113
8c3671ac09ee0b4b8e8da0 (Caused by ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory')))
[05/Nov/2022 17:25:52] "GET / HTTP/1.1" 500 158513
views.py:
import requests
from django.shortcuts import render
def index(request):
appid = 'cbf515c1138c3671ac09ee0b4b8e8da0'
url = 'https://api.openweathermap.org/data/2.5/weather?q={}&appid=' + appid
city ='London'
res = requests.get(url.format(city), verify=False)
print(res.text)
return render(request, 'weather/index.html')
Небольшая часть settings:
ALLOWED_HOSTS = ['127.0.0.1']
Понимаю, что проблема с прокси сервером, в настроках винды прокси у меня включен.