Created
July 25, 2024 10:28
-
-
Save fliepeltje/5be7d0a6f1ada057b1eb3aa357cd4961 to your computer and use it in GitHub Desktop.
FastAPI with boto3 on Fly.io
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import boto3 | |
from fastapi import FastAPI | |
S3_URL = os.getenv("AWS_ENDPOINT_URL_S3") | |
svc = boto3.client('s3', endpoint_url=S3_URL) | |
app = FastAPI() | |
@app.get("/") | |
async def read_root(): | |
buckets = svc.list_buckets() | |
return {"buckets": [bucket["Name"] for bucket in buckets["Buckets"]]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment