我正在使用 falcon 框架编写一个 WSGI Python Web 服务器应用程序。我wsgiref.simple_server
用于本地测试。
在我想测试将文件发布到我的服务器之前,它运行顺利。我的代码如下:
def on_post(self, req, resp):
""" handle files upload by user """
file_path = 'user_upload_file_' + str(uuid.uuid4())
with open(file_path, 'wb') as user_upload_file:
while True:
chunk = req.stream.read(4096)
if not chunk:
break
user_upload_file.write(chunk)
# ... give back response ...
一旦我将文件发布到我的 simple_server 托管应用程序,它似乎就挂在req.stream.read()
.
但是如果我使用 uWSGI 托管我的应用程序,那么这段代码运行良好。
这个问题与simple_server有关吗?