ServeDir 🚀
A lightweight, feature-rich HTTP server for serving directories with byte-range support, CGI scripting, and multi-threading.
Perfect for:
✔ Local development
✔ Sharing files quickly
✔ Testing large file downloads
✔ Serving static websites
Features ✨
✅ Directory Listing – Clean HTML interface with navigation links.
✅ Byte-Range Support – Partial downloads & streaming (Range header).
✅ CGI Support – Execute scripts with --cgi.
✅ Multi-Threaded – Handles concurrent requests efficiently.
✅ Configurable – Custom port, bind address, and root directory.
✅ Segment Support – Serve split/partial files (e.g., .parts.json).
☕ Support
If you find this project helpful, consider supporting me:
Usage 🛠
Basic Command
python -m serve_dir [DIR] # Serve current dir (or DIR) on http://0.0.0.0:8058
Options
| Flag | Description | Default |
|---|---|---|
-p, --port |
Port to listen on. | 8058 |
-b, --bind |
Bind address (e.g., 127.0.0.1). |
0.0.0.0 |
--byte-range |
Enable byte-range support. | None (auto) |
--cgi |
Enable CGI script execution. | None (auto) |
Examples
- Serve a specific directory on port 9000:
python -m serve_dir /path/to/files -p 9000
- Enable byte-range support for media streaming:
python -m serve_dir --byte-range
- Bind to localhost only:
python -m serve_dir -b 127.0.0.1
Segment Support 🔗
ServeDir includes built-in support for segmented files, making it ideal for serving large files split into smaller parts (e.g., downloads, media, or backups).
How It Works
- Detects segmented files automatically (e.g.,
.parts.jsonmetadata files). - Seamlessly stitches parts when requested, acting like a single file.
- Supports byte-range requests even across segments (e.g., streaming partial content).
Use Cases
- Large file downloads: Split a 10GB file into manageable chunks, but serve it as one.
- Resumable transfers: Byte-range support works across segments.
- Bandwidth efficiency: Clients download only the needed segments.
Example: Serving Segmented Files
- Prepare segments:
Split a file (e.g.,bigfile.zip) into parts and create abigfile.parts.json.zipmanifest:{ "length": 1024000000, // Total file size "parts": [ [0, 1000000, "bigfile.zip.001"], // [start, start+size, path] [1000000, 1999999, "bigfile.zip.002"] ] }
- Serve:
Place all parts +bigfile.parts.json.zipin your directory. ServeDir will handle the rest!python -m serve_dir /path/to/segmented_files --byte-range
- Clients see one file:
Requests tobigfile.parts.json.zipwill transparently combine segments.
Why Not Just python -m http.server? 🤔
This project extends Python’s built-in server with:
🔹 Better performance (threaded requests).
🔹 Byte-range support (e.g., for video streaming).
🔹 Nicer directory listings (with HTML/CSS).
🔹 CGI scripting out of the box.
🔹 Segment File Support Serve split/partial files.
Metadata
Release files for serve-dir 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| serve_dir-0.0.3.tar.gz | 27.1 kB | Without provenance | Details for serve_dir-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| serve_dir-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for serve_dir-0.0.3-py3-none-any.whl |
Total release size: 51.3 kB
Release files / serve_dir-0.0.3.tar.gz
| Download URL | serve_dir-0.0.3.tar.gz |
|---|---|
| Size | 27.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f61108702a253eda89f35cd49f6d59fb7699f7d09aa8cef2895043771cc8fe17
|
|
BLAKE2b-256 checksum How to use checksums |
7a71c9da27d2a15a8137b7aa3f50baed0ee5dcd45a3770ecdd28f86774bff931
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.17
|
Release files / serve_dir-0.0.3-py3-none-any.whl
| Download URL | serve_dir-0.0.3-py3-none-any.whl |
|---|---|
| Size | 24.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a42f7ce177e7d858ac2ee96cc87d553a0e38850ff0e73d14bfeafc50e10d6a99
|
|
BLAKE2b-256 checksum How to use checksums |
29f074d8ba839f9242af00e702172fb6bfb602d8d9518df8fe24ff5d46b515b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.17
|
Security for serve-dir 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.