myip 592 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/python3
  2. import os
  3. import sys
  4. def out(s=""):
  5. print(s, file=sys.stdout, end="\r\n")
  6. def outenv(name):
  7. val = os.environ.get(name)
  8. if val is None:
  9. val = ""
  10. val = val.replace("\r", " ").replace("\n", " ").replace("\0", " ")
  11. out(f"{name}={val}")
  12. out("Content-type: text/plain")
  13. out("Status: 200 Ok")
  14. out()
  15. for name in ("REMOTE_ADDR",
  16. "REMOTE_HOST",
  17. "REMOTE_PORT",
  18. "HTTPS",
  19. "REQUEST_METHOD",
  20. "REQUEST_URI",
  21. "HTTP_USER_AGENT",
  22. "HTTP_HOST",
  23. "HTTP_COOKIE",
  24. "HTTP_REFERER",
  25. "QUERY_STRING", ):
  26. outenv(name)
  27. sys.exit(0)