chris
chris

Reputation: 36957

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.

Upvotes: 0

Views: 672

Answers (2)

micebrain
micebrain

Reputation: 576

You can access custom header in Django view:

request.META.get("Custom_Header")

Upvotes: 2

squgeim
squgeim

Reputation: 2351

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).

Upvotes: 1

Related Questions