django - HTTPSConnectionPool(host='localhost', port=8000): url:/index 超出最大重试次数
问题描述
我正在使用 Django 2.2.10 并python manage.py runsslserver
用于在本地开发 https 站点。
我编写了一个身份验证应用程序,其视图函数将 JSON 数据返回为 ff:
def foobar(request):
data = {
'param1': "foo bar"
}
return JsonResponse(data)
我在父项目中调用这个函数如下:
def index(request):
scheme_domain_port = request.build_absolute_uri()[:-1]
myauth_login_links_url=f"{scheme_domain_port}{reverse('myauth:login_links')}"
print(myauth_login_links_url)
data = requests.get(myauth_login_links_url).json()
print(data)
当我导航到 https://localhost:8000myproj/index 时,我看到控制台中打印了正确的 URL,随后出现多个错误,最终导致此问题标题中显示的错误:
HTTPSConnectionPool(host='localhost', port=8000): 最大重试次数超过 url:/index (由 SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),) )
如何传递会话中使用的 SSL 证书(可能由runsslserver
请求模块生成)?
解决方案
尝试这个:
data = requests.get(myauth_login_links_url, verify=False).json()
推荐阅读
- awk - 如何仅在点之后删除第一列中的所有内容?
- sql - 在 PostgreSQL 中,我在 1000 行上执行 UPSERT,我正在使用 ON CONFLICT ... DO NOTHING,如果 1 行失败,是否插入其他 999?
- javascript - JQuery Ajax Success Handler 找不到类函数
- java - 将我的第二个活动中的图像的可见性设置为我的主要活动中的可见性?
- rest - 如何检索与在公共数据集上执行 Google BigQuery 相关的作业信息?
- c# - 有没有办法在 Azure Key Vault 中存储超过 25KB 的机密?
- javascript - 如何滚动到特定于桌面视图的 ID 并将其默认设置为移动视图?
- scala - Spark Streaming DF 并行处理
- python - 如何通过特定的浏览器作为参数。它的错误:py.test:错误:无法识别的参数:--browser IE
- java - 膨胀类 com.google.android.material.internal.NavigationMenuItemView 时出错