emptygif
言語: 日本語

すべての言語・フレームワーク

Quart Python

/pixel.gif へのリクエストに空の GIF を返す、Quart 用の Python スニペット。GIF は起動時に一度だけデコードします。

Quart Python

インストール
pip install quart
ファイル
app.py
実行
quart --app app run --port 8080
import base64

from quart import Quart, Response

GIF = base64.b64decode("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")

app = Quart(__name__)


@app.get("/pixel.gif")
async def pixel():
    return Response(GIF, mimetype="image/gif", headers={"Cache-Control": "no-store"})

このスニペットは実行し、返されたバイト列を照合しました。

確認

curl -sI http://localhost:8080/pixel.gif

公式サイト: Quart

Python の他の例