The http.server module writes a line to the terminal for every request it handles, including the client address, timestamp, request line, and response status code. Before Python 3.15, these lines were printed as plain text, making them difficult to read.
Since Python 3.15, the request log is colored by default:
python -m http.server 8000
Coloring applies only when the output is a terminal that supports it. Redirecting the log to a file leaves the text plain, so no escape sequences end up in the file.
Colored output is useful for most interactive work, but there would be situations where plain text is preferred. By setting the NO_COLOR environment variable, it is possible to disable coloring in the request log:
NO_COLOR=1 python -m http.server 8000
Leave a Comment
Cancel reply