Merge branch 'main' into avm99963-monorail

Merged commit 4137ed7879acadbf891e8c471108acb874dae886.

GitOrigin-RevId: b6100ffc5b1da355a35f37b13fcaaf746ee8b307
diff --git a/framework/template_helpers.py b/framework/template_helpers.py
index 5f383c3..52a25d7 100644
--- a/framework/template_helpers.py
+++ b/framework/template_helpers.py
@@ -166,6 +166,20 @@
     response.write(whole_page)
     logging.info('wrote response in %dms', int((time.time() - start) * 1000))
 
+  def WriteFlaskResponse(self, response, data, content_type=None):
+    """Write the parsed and filled in template to http server."""
+    if content_type:
+      response.content_type = content_type
+
+    response.status_code = data.get('http_response_code', httplib.OK)
+    whole_page = self.GetResponse(data)
+    if data.get('prevent_sniffing'):
+      for sniff_pattern, sniff_replacement in SNIFFABLE_PATTERNS.items():
+        whole_page = whole_page.replace(sniff_pattern, sniff_replacement)
+    start = time.time()
+    response.response = whole_page
+    logging.info('wrote response in %dms', int((time.time() - start) * 1000))
+
   def GetResponse(self, data):
     """Generate the text from the template and return it as a string."""
     template = self.GetTemplate()