使用httpx时遇到错误

使用httpx时遇到错误

折腾了一小时总结出来的经验教训

import httpx
client = httpx.Client()
response = client.get('http://localhost:5141')
print(response.status_code)

我执行上面代码时返回的结果是502, 但是我可以正常通过浏览器访问http://localhost:5141,使用requests库的get方法也可以访问网址, 为什么会出现这种情况?

import requests
response = requests.get('http://localhost:5141')
print(response)
# 返回结果为 

解决方法

关闭代理。

你可能感兴趣的:(httpx,数据库,服务器,python)