Skip to main content

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:

ko-fi

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

  1. Serve a specific directory on port 9000:
    python -m serve_dir /path/to/files -p 9000
    
  2. Enable byte-range support for media streaming:
    python -m serve_dir --byte-range
    
  3. 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.json metadata 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

  1. Prepare segments:
    Split a file (e.g., bigfile.zip) into parts and create a bigfile.parts.json.zip manifest:
    {
      "length": 1024000000, // Total file size
      "parts": [
        [0, 1000000, "bigfile.zip.001"], // [start,  start+size, path]
        [1000000, 1999999, "bigfile.zip.002"]
      ]
    }
    
  2. Serve:
    Place all parts + bigfile.parts.json.zip in your directory. ServeDir will handle the rest!
    python -m serve_dir /path/to/segmented_files --byte-range
    
  3. Clients see one file:
    Requests to bigfile.parts.json.zip will 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.

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)

Source distribution for serve-dir 0.0.3
File Size Uploaded
serve_dir-0.0.3.tar.gz 27.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for serve-dir 0.0.3
File Interpreter ABI Platform
serve_dir-0.0.3-py3-none-any.whl Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page