Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试将文件上传到服务器。上传文件时,可能会出现可用磁盘空间不足并引发异常的情况,导致关闭与客户端的连接而没有发回任何响应。我很好奇有没有办法发送响应并用包含状态消息的字符串Resource的结果来呈现它?json
Resource
json
我会尝试用一个try...except...块包围你的上传代码。
try...except...
try: # upload file except Exception: # send response to Resource