109109from app .notify_client .upload_api_client import upload_api_client
110110from app .notify_client .user_api_client import user_api_client
111111from app .url_converters import SimpleDateTypeConverter , TemplateTypeConverter
112+ from app .utils .api_health import is_api_down
112113from app .utils .govuk_frontend_jinja .flask_ext import init_govuk_frontend
113114from notifications_utils import logging , request_helper
114115from notifications_utils .formatters import (
@@ -158,11 +159,14 @@ def _csp(config):
158159 "https://www.googletagmanager.com" ,
159160 "https://www.google-analytics.com" ,
160161 "https://dap.digitalgov.gov" ,
162+ "https://cdn.socket.io" ,
161163 ],
162164 "connect-src" : [
163165 "'self'" ,
164166 "https://gov-bam.nr-data.net" ,
165167 "https://www.google-analytics.com" ,
168+ "http://localhost:6011" ,
169+ "ws://localhost:6011" ,
166170 ],
167171 "style-src" : ["'self'" , asset_domain ],
168172 "img-src" : ["'self'" , asset_domain , logo_domain ],
@@ -173,17 +177,22 @@ def create_app(application):
173177 @application .after_request
174178 def add_csp_header (response ):
175179 existing_csp = response .headers .get ("Content-Security-Policy" , "" )
176- response .headers ["Content-Security-Policy" ] = existing_csp + "; form-action 'self';"
180+ response .headers ["Content-Security-Policy" ] = (
181+ existing_csp + "; form-action 'self';"
182+ )
177183 return response
178- # @application.context_processor
179- # def inject_feature_flags():
180- # this is where feature flags can be easily added as a dictionary within context
181- # feature_about_page_enabled = application.config.get(
182- # "FEATURE_ABOUT_PAGE_ENABLED", False
183- # )
184- # return dict(
185- # FEATURE_ABOUT_PAGE_ENABLED=feature_about_page_enabled,
186- # )
184+
185+ @application .context_processor
186+ def inject_feature_flags ():
187+ # this is where feature flags can be easily added as a dictionary within context
188+ feature_socket_enabled = application .config .get ("FEATURE_SOCKET_ENABLED" , False )
189+ return dict (
190+ FEATURE_SOCKET_ENABLED = feature_socket_enabled ,
191+ )
192+
193+ @application .context_processor
194+ def inject_is_api_down ():
195+ return {"is_api_down" : is_api_down ()}
187196
188197 @application .context_processor
189198 def inject_initial_signin_url ():
0 commit comments