emptygif
Basa: Basa Jawa

Kabeh basa lan framework

Sanic Python

Snippet Python kanggo Sanic sing mangsuli request menyang /pixel.gif nganggo empty GIF, sing didekode sepisan nalika startup.

Sanic Python

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

Snippet iki wis dilakokake lan byte asile wis dibandhingake.

Priksa

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

Situs resmi: Sanic

Liyane ing Python