Skip to content

Instantly share code, notes, and snippets.

@anna-geller
Last active January 12, 2023 09:42
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anna-geller/279ba90e4fc3aebe04e55d16598804ca to your computer and use it in GitHub Desktop.
Save anna-geller/279ba90e4fc3aebe04e55d16598804ca to your computer and use it in GitHub Desktop.
import boto3
import pandas as pd
s3_bucket = "awebsite"
html_file = "sales_report.html"
df = pd.DataFrame([{'year': 2021, 'month': 8, 'order_status': 'unavailable', 'order_count': 48},
{'year': 2021, 'month': 8, 'order_status': 'delivered', 'order_count': 7069},
{'year': 2021, 'month': 8, 'order_status': 'invoiced', 'order_count': 15},
{'year': 2021, 'month': 8, 'order_status': 'shipped', 'order_count': 74},
{'year': 2021, 'month': 8, 'order_status': 'canceled', 'order_count': 34},
{'year': 2021, 'month': 8, 'order_status': 'processing', 'order_count': 29}])
df.to_html(html_file, index=False)
s3 = boto3.client("s3")
s3.upload_file(
Filename=html_file,
Bucket=s3_bucket,
Key=html_file,
ExtraArgs={"ContentType": "text/html", "ACL": "public-read"},
)
# URL that you can share with others
print(f"http://{s3_bucket}.s3.amazonaws.com/{html_file}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment