emptygif
Harshe: Hausa

Duk harsuna da frameworks

Bottle Python

Snippet na Python don Bottle da ke amsa requests zuwa /pixel.gif da empty GIF, wanda ake decoding ɗinsa sau ɗaya lokacin farawa.

Bottle Python

Girkawa
pip install bottle
Fayil
app.py
Gudanar
python app.py
import base64

from bottle import Bottle, response

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

app = Bottle()


@app.get("/pixel.gif")
def pixel():
    response.content_type = "image/gif"
    response.set_header("Cache-Control", "no-store")
    return GIF


if __name__ == "__main__":
    app.run(host="0.0.0.0", port=8080)

Mun gudanar da wannan snippet kuma mun kwatanta bytes ɗin da ya mayar.

Duba shi

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

Shafin hukuma: Bottle

Ƙari a Python