How to get http headers in flask?

后端 未结 4 1619
借酒劲吻你
借酒劲吻你 2020-11-28 23:17

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.

But I can\'t fin

4条回答
  •  清酒与你
    2020-11-28 23:57

    from flask import request
    request.headers.get('your-header-name')
    

    request.headers behaves like a dictionary, so you can also get your header like you would with any dictionary:

    request.headers['your-header-name']
    

提交回复
热议问题