emptygif
Wika: Filipino

Lahat ng language at framework

Sanic Python

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

Sanic Python

I-install
pip install sanic
File
server.py
Patakbuhin
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"})

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

Iba pa sa Python