如何在烧瓶中获取http标头? [英] How to get http headers in flask?
本文介绍了如何在烧瓶中获取http标头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是 Python 新手,使用 Python Flask 并生成 REST API 服务.
I am newbie to python and using Python Flask and generating REST API service.
我想检查发送给客户端的授权头.
I want to check authorization header which is sent the client.
但是我找不到在flask中获取HTTP标头的方法.
But I can't find way to get HTTP header in flask.
感谢获得 HTTP 标头授权的任何帮助.
Any help for getting HTTP header authorization is appreciated.
推荐答案
from flask import request
request.headers.get('your-header-name')
request.headers
就像一个字典,所以你也可以像使用任何字典一样获取你的标题:
request.headers
behaves like a dictionary, so you can also get your header like you would with any dictionary:
request.headers['your-header-name']
这篇关于如何在烧瓶中获取http标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文