3

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

FuzzyAmi
  • 7,543
  • 6
  • 45
  • 79

2 Answers2

3

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.

Benoît Latinier
  • 2,062
  • 2
  • 24
  • 36
0

I created the following process, as mentioned here to create a request with a file and metadata :

curl -F "metadata=<metadata.json" -F "file=@my-file.tar.gz" http://example.com/add-file

And then read the file and the metadata as follows:

file = request.files['file']
metadata = json.loads(request.form.get('metadata'))
Rene B.
  • 6,557
  • 7
  • 46
  • 72