【发布时间】:2020-12-01 14:41:35
【问题描述】:
我有两个 django 应用程序,目前在 localhost 上运行。我计划将它们放在两台不同的服务器上,但目前它们正在我的机器上运行。
应用程序A 正在:8000 上运行
应用程序B 正在:8010 上运行
当我尝试使用以下命令从A 向B 发出请求时:
import requests
requests.post('http://0.0.0.0:8010/api/plan', data=post_data)
我收到连接错误:
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='0.0.0.0', port=8010): Max retries exceeded with url: /api/plan (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f82fed36630>: Failed to establish a new connection: [Errno 111] Connection refused',))
在我的B 应用程序中,我有ALLOWED_HOSTS = ['*']
有人知道我错过了什么吗?
【问题讨论】:
-
我不知道 request 。但你可以考虑使用 django-cors-headers
-
@Ankit 我已经在使用 python 请求了