RangeHTTPServer
RangeHTTPServer is a Python module that provides a simple HTTP server with support for HTTP Range requests, extending Python's built-in SimpleHTTPServer. It enables clients to request portions of files, which is particularly useful for media streaming, download managers, or local web development involving large data files. The project is sporadically maintained but active, with its latest version 1.4.0 released in August 2024.
Warnings
- gotcha RangeHTTPServer is explicitly designed for local testing and should NOT be used for Internet-scale production environments due to potential security and performance limitations inherent in a simple HTTP server.
- gotcha The library's Range header support is partial. It handles basic byte range requests but does not implement the full HTTP Range specification, specifically lacking support for multiple ranges or multipart payloads. Unparsable range requests will result in the entire file being served.
- gotcha In versions prior to 1.4.0, there was a known issue where specifying a port number from the command line (e.g., `python -m RangeHTTPServer 8080`) might be ignored, defaulting to port 8000. This has been addressed in version 1.4.0 with the addition of explicit `--bind` and port handling.
Install
-
pip install rangehttpserver
Imports
- RangeRequestHandler
from rangehttpserver import RangeRequestHandler
Quickstart
python -m rangehttpserver --bind 127.0.0.1 8000 # Access your files at http://127.0.0.1:8000 # For example, create a file: echo 'Hello, Range!' > index.html