我在 server.py 文件中编写了如下所示的一些函数。
import requests
@app.route('/similarwords')
def test():
url = 'http://127.0.0.1:8000/api/searchActivity'
response = requests.get(url)
print response
在运行服务器时,我向“similarwords”端点发出请求。在 requests.get(url) 服务器被阻塞。在向其他网址发送请求时,例如“www.google.com”服务正确。
在 python 控制台上它执行得很好。
>> import requests
>> requests.get("http://127.0.0.1:8000/api/searchActivity")
>> Response[200]
有什么问题。我正在本地主机中执行我的项目。