Raw WSGI (Gunicorn, uWSGI, mod_wsgi) Python
Đoạn mã Python cho Raw WSGI (Gunicorn, uWSGI, mod_wsgi), trả lời các yêu cầu tới /pixel.gif bằng GIF rỗng, được giải mã một lần khi khởi động.
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"]
Chúng tôi đã chạy đoạn mã này và so sánh các byte nó trả về.
Kiểm tra
curl -sI http://localhost:8080/pixel.gif
Trang chính thức: Raw WSGI (Gunicorn, uWSGI, mod_wsgi)