emptygif
Wika: Filipino

Lahat ng language at framework

FastHTML Python

Isang Python snippet para sa FastHTML na sumasagot sa mga request sa /pixel.gif gamit ang empty GIF, na isang beses lang dine-decode sa startup.

FastHTML Python

I-install
pip install python-fasthtml
File
main.py
Patakbuhin
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)

Pinatakbo namin ang snippet na ito at ikinumpara ang mga byte na ibinalik nito.

Suriin

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

Opisyal na site: FastHTML

Iba pa sa Python