emptygif
Dil: Türkçe

Tüm diller ve framework'ler

Raw WSGI (Gunicorn, uWSGI, mod_wsgi) Python

Raw WSGI (Gunicorn, uWSGI, mod_wsgi) için, /pixel.gif isteklerine başlangıçta bir kez çözülen boş GIF ile yanıt veren bir Python örneği.

Raw WSGI (Gunicorn, uWSGI, mod_wsgi) Python

Kurulum
pip install gunicorn
Dosya
app.py
Çalıştır
gunicorn --bind :8080 app:app
import base64

GIF = base64.b64decode("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")
HEADERS = [
    ("Content-Type", "image/gif"),
    ("Content-Length", str(len(GIF))),
    ("Cache-Control", "no-store"),
]


def app(environ, start_response):
    if environ["REQUEST_METHOD"] == "GET" and environ["PATH_INFO"] == "/pixel.gif":
        start_response("200 OK", HEADERS)
        return [GIF]
    start_response("404 Not Found", [("Content-Type", "text/plain")])
    return [b"Not Found"]

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: Raw WSGI (Gunicorn, uWSGI, mod_wsgi)

Python için daha fazlası