Try fix for Font files
This commit is contained in:
+16
-1
@@ -7,6 +7,7 @@ from logging.handlers import RotatingFileHandler
|
|||||||
from flask import render_template
|
from flask import render_template
|
||||||
from flask_migrate import upgrade
|
from flask_migrate import upgrade
|
||||||
import awsgi
|
import awsgi
|
||||||
|
import base64
|
||||||
|
|
||||||
app = create_app()
|
app = create_app()
|
||||||
|
|
||||||
@@ -44,7 +45,21 @@ if __name__ == '__main__':
|
|||||||
app.run(host='0.0.0.0', port=5004)
|
app.run(host='0.0.0.0', port=5004)
|
||||||
|
|
||||||
def lambda_handler(event, context):
|
def lambda_handler(event, context):
|
||||||
return awsgi.response(app, event, context)
|
response = awsgi.response(app, event, context)
|
||||||
|
headers = response.get("headers", {})
|
||||||
|
content_type = headers.get("Content-Type", headers.get("content-type", ""))
|
||||||
|
# List of binary content types (add more as needed)
|
||||||
|
binary_types = ["application/octet-stream", "image/", "application/pdf"]
|
||||||
|
if any(content_type.startswith(b) for b in binary_types):
|
||||||
|
# Base64 encode the body if not already encoded
|
||||||
|
if not response.get("isBase64Encoded"):
|
||||||
|
body = response["body"]
|
||||||
|
if isinstance(body, str):
|
||||||
|
# Try to encode as latin1 to preserve binary data
|
||||||
|
body = body.encode("latin1")
|
||||||
|
response["body"] = base64.b64encode(body).decode("utf-8")
|
||||||
|
response["isBase64Encoded"] = True
|
||||||
|
return response
|
||||||
|
|
||||||
def lambda_handler_upgrade_db(event, context):
|
def lambda_handler_upgrade_db(event, context):
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
|
|||||||
Reference in New Issue
Block a user