|
@@ -182,20 +182,23 @@ async def download(request: Request, response: Response, tag: str):
|
|
try:
|
|
try:
|
|
# --- get ---
|
|
# --- get ---
|
|
params = request.query_params
|
|
params = request.query_params
|
|
- # methods.debug_log('api.download|185', f"#code: {params.get('code')} | {type(params.get('code'))}")
|
|
|
|
- # methods.debug_log('api.download|185', f"#tag: {tag}")
|
|
|
|
|
|
+ methods.debug_log('api.download|185', f"#code: {params.get('code')} | {type(params.get('code'))}")
|
|
|
|
+ methods.debug_log('api.download|185', f"#tag: {tag}")
|
|
|
|
+ methods.debug_log('api.download|185', f"#params: {params}")
|
|
method = _get_method_by_code(code=int(params.get('code')), tag=tag)
|
|
method = _get_method_by_code(code=int(params.get('code')), tag=tag)
|
|
result = await method(**params)
|
|
result = await method(**params)
|
|
|
|
|
|
# --- 是否弹框 ---
|
|
# --- 是否弹框 ---
|
|
- if True:
|
|
|
|
- return FileResponse(result.get('file_path'),
|
|
|
|
- media_type="application/octet-stream", filename=result.get('file_name'))
|
|
|
|
|
|
+ if result.get('code') == 0:
|
|
|
|
+ if True:
|
|
|
|
+ return FileResponse(result.get('file_path'),
|
|
|
|
+ media_type="application/octet-stream", filename=result.get('file_name'))
|
|
|
|
+ else:
|
|
|
|
+ return FileResponse(result.get('file_path'))
|
|
else:
|
|
else:
|
|
- return FileResponse(result.get('file_path'))
|
|
|
|
-
|
|
|
|
|
|
+ return result
|
|
except Exception as exception:
|
|
except Exception as exception:
|
|
- methods.debug_log('api.download.249', f"#exception: {exception}")
|
|
|
|
- methods.debug_log('api.download.249', f"#traceback: {methods.trace_log()}")
|
|
|
|
|
|
+ methods.debug_log('api.download|200', f"#exception: {exception}")
|
|
|
|
+ methods.debug_log('api.download|200', f"#traceback: {methods.trace_log()}")
|
|
return dict(code=-1, message=f"something is wrong. [{exception.__class__.__name__}]",
|
|
return dict(code=-1, message=f"something is wrong. [{exception.__class__.__name__}]",
|
|
details=f"{methods.trace_log()}")
|
|
details=f"{methods.trace_log()}")
|