简体   繁体   中英

Python is there a way to read custom headers and send a response back

Ok so I am new to python as a whole. That said I don't know what I'm really looking for to ask this question properly. I know this has to be possible though. I want to ask this before really digging in and finding out I did something wrong and have to do it all over.

All in all what I want to know is, from the front end of my stack I want to pass down custom HTTP headers (which I can do with my Ajax calls, currently). The question is how do I actually read said headers? Similarly how can I pass back up from the server custom headers via python.

您可以在Django视图中访问自定义标头:

request.META.get("Custom_Header")

For django: How to add an HTTP header to all Django responses

You can definitely do it in the front end. You can do it with Javascript's native XMLHttpRequest , the newer fetch API , jQuery , or some other library (like axios ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM