emptygif
ভাষা: বাংলা

সব ভাষা ও ফ্রেমওয়ার্ক

Raw WSGI (Gunicorn, uWSGI, mod_wsgi) Python

Raw WSGI (Gunicorn, uWSGI, mod_wsgi)-এর জন্য একটি Python স্নিপেট, যা /pixel.gif-এ আসা রিকোয়েস্টের উত্তরে empty GIF পাঠায়। GIF-টি স্টার্টআপে একবারই ডিকোড হয়।

Raw WSGI (Gunicorn, uWSGI, mod_wsgi) Python

ইনস্টল
pip install gunicorn
ফাইল
app.py
চালান
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"]

আমরা এই স্নিপেট চালিয়েছি এবং এটি যে বাইটগুলো ফেরত দিয়েছে তা মিলিয়ে দেখেছি।

যাচাই করুন

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

অফিশিয়াল সাইট: Raw WSGI (Gunicorn, uWSGI, mod_wsgi)

Python-এ আরও