From eeee15b369818d4d43c79b98fa8cfde85cbb7035 Mon Sep 17 00:00:00 2001 From: Hossam Hammady Date: Sat, 18 May 2024 12:23:41 -0400 Subject: [PATCH] Return correct content type in Lambda handler --- handler.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/handler.py b/handler.py index e011eb4..ae9348e 100755 --- a/handler.py +++ b/handler.py @@ -1,4 +1,4 @@ -from flask import Flask, render_template +from flask import Flask, render_template_string from qusasat import Qusasat import base64 @@ -15,7 +15,14 @@ def run(event, context): global app, qusasat, base64_string quote = qusasat.get_random_quote() with app.app_context(): - return render_template('quote.html', + body = render_template_string('quote.html', category=quote['category'], quote=quote['quote'], background_image_url=f'data:image/png;base64,{base64_string}') + return { + "statusCode": 200, + "headers": { + "Content-Type": "text/html" + }, + "body": body + }