Skip to content

Commit

Permalink
Return correct content type in Lambda handler
Browse files Browse the repository at this point in the history
  • Loading branch information
hammady committed May 18, 2024
1 parent 2c93395 commit eeee15b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions handler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask import Flask, render_template
from flask import Flask, render_template_string
from qusasat import Qusasat
import base64

Expand All @@ -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
}

0 comments on commit eeee15b

Please sign in to comment.