API¶
NoFLoC¶
-
class
flask_nofloc.NoFLoC(app=None)¶ The base extension class.
-
init_app(app)¶ Adds
_add_nofloc_header()as anflask.Flask.after_request()hook to the app.- Parameters
app (
flask.Flask) – A Flask app.
-
-
flask_nofloc.add_nofloc_header(view_function)¶ Adds the
Permission-Policyheader to a result from a view function.This is supposed to be used as a decorator and should come after the
flask.Flask.route()orflask.Blueprint.route()decorator:@app.route('/nofloc') @add_nofloc_header def nofloc_route(): return 'response'
- Parameters
view_function (
callable()) – A view function, see Blueprints and Views.
-
flask_nofloc._add_nofloc_header(response)¶ Adds the
Permission-Policyheader to aResponse.This is an internal function and is called by
add_nofloc_header()and registered as anflask.Flask.after_request()hook inNoFLoC.init_app().The function adds the
Permission-Policyheader with a value ofinterest-cohort=()unless it is already present.- Parameters
response (
flask.Response) – A response object.