mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-22 13:05:18 +00:00
refactor: 迁移前端资源文件至web目录 feat: 新增多种图标资源 style: 统一代码风格和格式化配置 docs: 更新README和文档说明 chore: 更新依赖和配置文件 fix: 修复部分类型定义和枚举 perf: 优化路由和组件加载逻辑
35 lines
979 B
Python
35 lines
979 B
Python
# -*- coding: utf-8 -*-
|
|
|
|
import logging
|
|
import requests
|
|
|
|
class Response:
|
|
def __init__(self):
|
|
pass
|
|
|
|
def result(self, res: requests.Response) -> dict:
|
|
"""
|
|
:param res: requests响应对象
|
|
:return: 格式化后的响应字典
|
|
"""
|
|
try:
|
|
response_dicts = dict()
|
|
|
|
# 响应状态码
|
|
response_dicts['code'] = res.status_code
|
|
|
|
# 响应body
|
|
response_body = res.json()
|
|
|
|
# 确保响应体是字典格式
|
|
if isinstance(response_body, dict):
|
|
response_dicts['body'] = response_body
|
|
|
|
# 响应秒时间
|
|
response_dicts['time_total'] = res.elapsed.total_seconds() # 秒为单位
|
|
|
|
logging.info(f"【请求响应结果为: {response_dicts}】")
|
|
return response_dicts
|
|
except Exception as e:
|
|
logging.error(f"响应结果处理异常:{e}")
|