Hello,
This is a test HTTP server.
Your request came from {ip_html}.
{proxy_headers_html}Have a nice day!
#!/usr/bin/env python3 """Simple HTTP server that responds 200 with a test message including client IP. Behavior: - GET returns HTTP/1.1 200 with a message including the requester IP - HEAD returns the same headers as GET but no body - Displays whether any incoming X-* headers were detected and lists them - If User-Agent contains "curl" or "wget" (case-insensitive) the server responds with Content-Type: text/plain; otherwise Content-Type: text/html. - --pem path to a PEM bundle (cert chain + private key). When provided, the server listens on both HTTP (--port) and HTTPS (--tls-port). Without --pem the server listens on plain HTTP only. - --look controls which HTML variant is returned for non-CLI agents: * basic - plain HTML with no external references * nice - includes Google Font "Noto Sans" (default) * bootstrap - Bootstrap 5 layout * tailwind - Tailwind CSS via @tailwindcss/browser@latest - The URL query parameter "look" (e.g. /?look=nice) overrides the command-line --look for that request only. Values are case-insensitive and must be one of basic,nice,bootstrap,tailwind. Usage: python3 ok_server.py # binds 0.0.0.0:8080, nice look python3 ok_server.py --look basic python3 ok_server.py -b 127.0.0.1 -p 8080 --look tailwind python3 ok_server.py --pem /path/to/bundle.pem # HTTP :8080 + HTTPS :8443 python3 ok_server.py --pem /path/to/bundle.pem --tls-port 9443 Test: curl -i http://localhost:8080/ # text/plain for curl curl -i "http://localhost:8080/?look=basic" # request-level override curl -I http://localhost:8080/ # HEAD (headers only) wget -S -O - http://localhost:8080/ # text/plain for wget open http://localhost:8080/ # browser gets HTML variant per look """ import argparse import signal import ssl import sys import threading from html import escape from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer from typing import Tuple from urllib.parse import urlparse, parse_qs PLAIN_TEMPLATE = ( "Hello, This is a test HTTP server.\n\n" "Your request came from {ip}.\n\n" "{proxy_headers_block}" "Have a nice day!\n" ) HTML_BASIC = """
This is a test HTTP server.
Your request came from {ip_html}.
{proxy_headers_html}Have a nice day!
""" HTML_NICE = """This is a test HTTP server.
Your request came from {ip_html}.
{proxy_headers_html}Have a nice day!
This is a test HTTP server.
Your request came from {ip_html}.
{proxy_headers_html}Have a nice day!
Simple status page for firewall/testing
Hello,
This is a test HTTP server.
Your request came from {ip_html}.
{proxy_headers_html}Have a nice day!
{escape(name)}: {escape(value)}Reverse proxy condition: detected via X-* headers.
" "X-* headers: