Google Cloud Run functions (Python) Python
Đoạn mã Python cho Google Cloud Run functions (Python), trả lời các yêu cầu tới /pixel.gif bằng GIF rỗng, được giải mã một lần khi khởi động.
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"}
Chúng tôi đã chạy đoạn mã này và so sánh các byte nó trả về.
Kiểm tra
curl -sI http://localhost:8080/pixel.gif
Trang chính thức: Google Cloud Run functions (Python)