AWS Lambda (Python) Python
AWS Lambda (Python) साठी Python स्निपेट, जो /pixel.gif वरच्या रिक्वेस्टना empty GIF ने उत्तर देतो. GIF स्टार्टअपला एकदाच डिकोड होतो.
AWS Lambda (Python) Python
# lambda_function.py - behind an API Gateway HTTP API route "GET /pixel.gif" or a function URL.
# Binary bodies travel base64-encoded, so the GIF stays in base64 here.
GIF_BASE64 = "R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
def lambda_handler(event, context):
return {
"statusCode": 200,
"headers": {"Content-Type": "image/gif", "Cache-Control": "no-store"},
"body": GIF_BASE64,
"isBase64Encoded": True,
}
आम्ही हा स्निपेट चालवला आणि त्याने परत केलेले बाइट्स तुलना करून पाहिले.
तपासा
curl -sI http://localhost:8080/pixel.gif
अधिकृत साइट: AWS Lambda (Python)