python - 如何添加 API 在 JSON 响应中响应所需的执行时间 - 带有烧瓶的 Python
问题描述
如何添加 API 响应 JSON 响应所需的执行时间
I would like to add the time taken by the API to respond in the response JSON. Currently calling an API using python with flask
If anyone can guide with best approach.
Note:I have updated the question
解决方案
如果您正在使用该requests
库,则该Response
对象将返回一个elapsed
属性。此属性为您提供请求和响应之间的时间增量。例如:
res = requests.get(url)
print(res.elapsed)
推荐阅读
- angular - 使用API(https)时如何获取数组的长度?
- c# - MySql Connection 连接数据库失败
- javascript - create-react-native-app 不再工作了?
- ssis - SSIS:平面文件源将其转换为两个 OLE DB SQL 表(在加载到 OLEDB 源之前转换和排序时抛出错误)
- html - 通过文件字段接受 jpg 和 jpeg 图像
- python - Robust way to sum all values corresponding to a particular objects property?
- javascript - JavaScript setTimeout() 和数组
- javascript - 为什么变换会移动整个坐标系而不是仅移动 SVG 中的元素?
- python - 根据数据长度创建具有特定行为的循环
- sql - 如何在 SSRS 报告中添加按钮并单击按钮将 tablix 数据集传递到本地服务器,本地服务器将在 excel 中导出数据集