diff --git a/.gitignore b/.gitignore index 72383bb..8d16a1a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .venv .env __pycache__ -.vscode \ No newline at end of file +.vscode +.idea \ No newline at end of file diff --git a/app/routers/embed.py b/app/routers/embed.py index f3f36aa..f895db8 100644 --- a/app/routers/embed.py +++ b/app/routers/embed.py @@ -63,7 +63,8 @@ def load_latest_statuses(url, token, limit): raise Exception('Failed to contact Mastodon', response.text) return json.loads(response.text) -def convertToHTML(statuses): + +def convertToHTML(statuses) -> str: css_file = Path(__file__).parent / '../resources/embed.css' with css_file.open('r') as css: doc, tag, text = Doc().tagtext() @@ -96,7 +97,8 @@ def convertToHTML(statuses): return indent(doc.getvalue()) -def uploadToAmazonS3(bucket, key, content): +def uploadToAmazonS3(bucket, key, content:str): + logger.info(f'Uploading embed html to {bucket}/{key}') s3 = boto3.resource('s3') - object = s3.Object(bucket, key) # type: ignore - object.put(Body=content, ACL='public-read', ContentType='text/html') \ No newline at end of file + s3_object = s3.Object(bucket, key) + s3_object.put(Body=content.encode("utf-8"), ACL='public-read', ContentType='text/html') \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index ca6cfa6..55d4dc0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ fastapi[standard]==0.113.0 pydantic==2.8.0 pydantic-settings==2.12.0 requests==2.32.3 -boto3==1.36.21 +boto3==1.35.48 # Note: Upgrading might break boto3 upload with XAmzContentSHA256Mismatch errors yattag==1.16.1 timeago==1.0.16 certifi==2024.12.14