Google Cloud Run functions (Python) Python
/pixel.gif へのリクエストに空の GIF を返す、Google Cloud Run functions (Python) 用の Python スニペット。GIF は起動時に一度だけデコードします。
Google Cloud Run functions (Python) Python
import base64
import functions_framework
GIF = base64.b64decode("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")
@functions_framework.http
def pixel(request):
if request.path != "/pixel.gif":
return "Not Found", 404
return GIF, 200, {"Content-Type": "image/gif", "Cache-Control": "no-store"}
このスニペットは実行し、返されたバイト列を照合しました。
確認
curl -sI http://localhost:8080/pixel.gif
公式サイト: Google Cloud Run functions (Python)