emptygif
Dil: Türkçe

Tüm diller ve framework'ler

Sanic Python

Sanic için, /pixel.gif isteklerine başlangıçta bir kez çözülen boş GIF ile yanıt veren bir Python örneği.

Sanic Python

Kurulum
pip install sanic
Dosya
server.py
Çalıştır
sanic server:app --port 8080
import base64

from sanic import Sanic
from sanic.response import raw

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

app = Sanic("pixel")


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

Bu örneği çalıştırıp döndürdüğü baytları karşılaştırdık.

Kontrol et

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

Resmî site: Sanic

Python için daha fazlası