Enhanced HTTP directory server with byte-range support, CGI, and segment handling
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file serve_dir-0.0.3.tar.gz.
File metadata
- Download URL: serve_dir-0.0.3.tar.gz
- Upload date:
- Size: 27.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f61108702a253eda89f35cd49f6d59fb7699f7d09aa8cef2895043771cc8fe17
|
|
| MD5 |
3fc6a68d892054d91500d44b994f6ea5
|
|
| BLAKE2b-256 |
7a71c9da27d2a15a8137b7aa3f50baed0ee5dcd45a3770ecdd28f86774bff931
|
File details
Details for the file serve_dir-0.0.3-py3-none-any.whl.
File metadata
- Download URL: serve_dir-0.0.3-py3-none-any.whl
- Upload date:
- Size: 24.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a42f7ce177e7d858ac2ee96cc87d553a0e38850ff0e73d14bfeafc50e10d6a99
|
|
| MD5 |
0665c8e62d69267eb13df822ed498f6e
|
|
| BLAKE2b-256 |
29f074d8ba839f9242af00e702172fb6bfb602d8d9518df8fe24ff5d46b515b2
|