#!/usr/bin/python3 import os import sys def out(s=""): print(s, file=sys.stdout, end="\r\n") def outenv(name): val = os.environ.get(name) if val is None: val = "" val = val.replace("\r", " ").replace("\n", " ").replace("\0", " ") out(f"{name}={val}") out("Content-type: text/plain") out("Status: 200 Ok") out() for name in ("REMOTE_ADDR", "REMOTE_HOST", "REMOTE_PORT", "HTTPS", "REQUEST_METHOD", "REQUEST_URI", "HTTP_USER_AGENT", "HTTP_HOST", "HTTP_COOKIE", "HTTP_REFERER", "QUERY_STRING", ): outenv(name) sys.exit(0)