Send HTTP header as well as inserting meta tag

This will let us use the decorator on endpoints that don’t return HTML.
This commit is contained in:
Chris Hill-Scott
2020-05-27 09:03:14 +01:00
parent f12f0fae87
commit 978ebcbe9b
2 changed files with 23 additions and 5 deletions

View File

@@ -16,7 +16,16 @@ import pyexcel
import pyexcel_xlsx
import pytz
from dateutil import parser
from flask import abort, current_app, g, redirect, request, session, url_for
from flask import (
abort,
current_app,
g,
make_response,
redirect,
request,
session,
url_for,
)
from flask_login import current_user, login_required
from notifications_utils.field import Field
from notifications_utils.formatters import (
@@ -773,5 +782,7 @@ def hide_from_search_engines(f):
@wraps(f)
def decorated_function(*args, **kwargs):
g.hide_from_search_engines = True
return f(*args, **kwargs)
response = make_response(f(*args, **kwargs))
response.headers['X-Robots-Tag'] = 'noindex'
return response
return decorated_function