向eve服务器发送请求封锁,但是来自python shell

2024-09-30 14:28:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我在中编写了一些函数,如下所示服务器.py文件。你知道吗

import requests 
@app.route('/similarwords')
def test():
    url = 'http://127.0.0.1:8000/api/searchActivity'
    response = requests.get(url)
    print response

在运行服务器时,我向“similarwords”端点发出请求。在请求。获取(url)服务器被阻止。 同时向其他URL发送请求示例“www.google.com“发球正确。你知道吗

在python控制台上,它执行得很好。你知道吗

>> import requests
>> requests.get("http://127.0.0.1:8000/api/searchActivity") 
>> Response[200]

有什么问题。我正在localhost中执行我的项目。你知道吗


Tags: 文件函数pyimport服务器apiapphttp
1条回答
网友
1楼 · 发布于 2024-09-30 14:28:40

您没有提到“阻塞”是仅在本地设置中发生,还是在生产中发生。我想它只是本地的。你知道吗

结果是

the development server is single threaded, so when you call a url served by that application from within the application itself, you create a deadlock situation.

我以前也遇到过这个问题,并发现了它here。 本文还建议在本地使用gunicorn之类的解决方法来克服“限制”,并警告说,在heroku自由层类型设置中,问题可能会再次出现。你知道吗

相关问题 更多 >