Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

request.META in flask?

Tags:

flask

It appears Django has request.META: a dictionary of the request's headers in CAPITAL_UNDERSCORE format - like: "X_FORWARDED_FOR".

Is there a similar construct for Flask?

(I am aware of flask's request.headers (which contains headers in "x-forwarded-for" format))

like image 328
FuzzyAmi Avatar asked Nov 16 '25 03:11

FuzzyAmi


1 Answers

This is the way for the framework to expose headers. Django chooses to expose it full capital with underscores and the real input from the server is something like that: X-Forwarded-For on apache2.

All this to say that Flask expose you headers in only one way. You can always convert it using .upper().replace('-', '_') if you really need it.

like image 190
Benoît Latinier Avatar answered Nov 17 '25 17:11

Benoît Latinier



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!