emptygif
Bahasa: Bahasa Indonesia

Semua bahasa dan framework

Microdot (CPython and MicroPython) Python

Snippet Python untuk Microdot (CPython and MicroPython) yang menjawab request ke /pixel.gif dengan empty GIF, yang di-decode sekali saat startup.

Microdot (CPython and MicroPython) Python

Instal
pip install microdot
File
app.py
Jalankan
python app.py
import binascii  # available on MicroPython as well as CPython

from microdot import Microdot

GIF = binascii.a2b_base64("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")

app = Microdot()


@app.get("/pixel.gif")
async def pixel(request):
    return GIF, 200, {"Content-Type": "image/gif", "Cache-Control": "no-store"}


app.run(port=8080)

Kami telah menjalankan snippet ini dan membandingkan byte yang dikembalikannya.

Periksa

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

Situs resmi: Microdot (CPython and MicroPython)

Lainnya dalam Python