-
I've got a medium sized API all up and running, but one of the frontend devs is claiming the browser is caching the response from one of the endpoints. So I'd like to set the Cache-Control header. Flask-rebar abstracts away the process of creating a response so I see no way to set the headers in it. I see flask-rebar has a response function but attempts to return response(data) from my endpoint function have been unsuccessful. Any tips? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Ah, this is indeed lacking in the documentation. You can return a tuple of Here’s the source code, if you want to see exactly how the response is interpreted: https://github.com/plangrid/flask-rebar/blob/master/flask_rebar/rebar.py#L78 Hope that helps. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick field of that question Barak! I'll add a ticket to shore up the documentation (and, with any luck, I'm actually going to have some time to work on Rebar next week in the slack tide between monster projects and Hackweek 🤣 ) |
Beta Was this translation helpful? Give feedback.
Ah, this is indeed lacking in the documentation.
You can return a tuple of
(response, status, headers)
or(response, headers)
from a view function, similar to Flask view functions: https://flask.palletsprojects.com/en/2.0.x/quickstart/#about-responsesHere’s the source code, if you want to see exactly how the response is interpreted: https://github.com/plangrid/flask-rebar/blob/master/flask_rebar/rebar.py#L78
Hope that helps.