emptygif
Dil: Türkçe

Tüm diller ve framework'ler

FastHTML Python

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

FastHTML Python

Kurulum
pip install python-fasthtml
Dosya
main.py
Çalıştır
python main.py
from base64 import b64decode

from fasthtml.common import FastHTML, Response, serve

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

# Not fast_app(): it adds a static-file route that would claim *.gif paths first.
app = FastHTML()


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


serve(port=8080)

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: FastHTML

Python için daha fazlası