emptygif
Dil: Türkçe

Tüm diller ve framework'ler

FastAPI Python

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

FastAPI Python

Kurulum
pip install "fastapi[standard]"
Dosya
main.py
Çalıştır
fastapi run main.py --port 8080
import base64

from fastapi import FastAPI, Response

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

app = FastAPI()


@app.get("/pixel.gif", include_in_schema=False)
def pixel() -> Response:
    return Response(GIF, media_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: FastAPI

Python için daha fazlası