Raw WSGI (Gunicorn, uWSGI, mod_wsgi) Python
Raw WSGI (Gunicorn, uWSGI, mod_wsgi) ਲਈ Python ਸਨਿੱਪਟ, ਜੋ /pixel.gif ਦੀਆਂ ਬੇਨਤੀਆਂ ਦਾ ਜਵਾਬ ਖਾਲੀ GIF ਨਾਲ ਦਿੰਦਾ ਹੈ; GIF ਸ਼ੁਰੂਆਤ ’ਤੇ ਇੱਕ ਵਾਰ ਡੀਕੋਡ ਹੁੰਦੀ ਹੈ।
Raw WSGI (Gunicorn, uWSGI, mod_wsgi) Python
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)