[英]How Can I get the timestamp a request was sent from the client?
I want to calculate the delay between a client sending a request to my flask api and my flask api receiving the request. 我想计算客户端向我的flask api发送请求和我的flask api接收请求之间的延迟。 Right now I'm trying this:
现在,我正在尝试:
@current_app.before_request
def before_request():
print(request.date)
But I am printing None
但我打印
None
Flask's documentation states this will work here: http://werkzeug.pocoo.org/docs/0.14/wrappers/#werkzeug.wrappers.CommonRequestDescriptorsMixin.date Flask的文档指出可以在此处使用: http : //werkzeug.pocoo.org/docs/0.14/wrappers/#werkzeug.wrappers.CommonRequestDescriptorsMixin.date
Those flask docs are referencing the Date
header. 这些烧瓶文档引用了
Date
标头。 It will print None
unless the Date
header is specified in the request. 除非在请求中指定了
Date
标头,否则它将打印None
。
The MDN Docs for header show you the format of the header. 标头的MDN文档显示标头的格式。 Send a request with that header and you'll have the information you need.
发送带有该标头的请求,您将获得所需的信息。
If you can't control the client sending your requests, I don't think there is a way to achieve what you're looking for. 如果您无法控制发送请求的客户端,那么我认为没有一种方法可以实现您所需要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.