gpt4 book ai didi

python - Flask:一段时间后服务器变得无响应

转载 作者:行者123 更新时间:2023-11-28 16:36:26 29 4
gpt4 key购买 nike

我使用 flask 服务器从服务器提供静态文件,但有时服务器变得完全无响应,下载文件一直在加载但从未下载。当我打开终端时,我发现了一些奇怪的请求,我按下 CTRL + C,服务器立即再次响应并继续下载。这种情况经常发生,我不知道是什么原因造成的,也不知道如何防止它卡住我的 flask 服务器,这是有人试图破解吗?

user@server:~/worker# python server.py
* Running on http://0.0.0.0:80/
93.134.13.318 - - [03/Sep/2014 02:07:18] code 400, message Bad request syntax ('\x00')
93.134.13.318 - - [03/Sep/2014 02:07:18] "" 400 -
93.134.13.318 - - [03/Sep/2014 02:07:19] "GET http://httpheader.net HTTP/1.1" 404 -
93.134.13.318 - - [03/Sep/2014 02:07:40] code 400, message Bad request syntax ('\x04\x01\x00P\xc6\xce\x0eu0\x00')
93.174.93.218 - - [03/Sep/2014 02:07:40] "P��u0" 400 -
^C----------------------------------------
Exception happened during processing of request from ('93.174.93.218 ', 45082)
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 284, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 310, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.7/SocketServer.py", line 638, in __init__
self.handle()
File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 200, in handle
rv = BaseHTTPRequestHandler.handle(self)
File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
self.handle_one_request()
File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 231, in handle_one_request
self.raw_requestline = self.rfile.readline()
File "/usr/lib/python2.7/socket.py", line 447, in readline
data = self._sock.recv(self._rbufsize)
KeyboardInterrupt
----------------------------------------
42.36.63.90 - - [03/Sep/2014 03:21:20] "GET / HTTP/1.1" 404 -
63.63.193.195 - - [03/Sep/2014 03:21:20] "GET / HTTP/1.1" 404 -

最佳答案

我遇到了同样的问题。在 django/flask 应用程序中,当以 python server.py 运行时挂起是很常见的,因为这不是它们的最佳环境。仅将其用于测试目的。当你用完它并想发布时,你应该把它放在 wsgi/uwsgi + apache/nginx 后面,你的问题就会消失。

<德尔> http://flask.pocoo.org/docs/0.10/deploying/uwsgi/

http://flask.pocoo.org/docs/1.0/deploying/uwsgi/

关于python - Flask:一段时间后服务器变得无响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25641854/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com