Ultra-fast, lightweight HTTP server for Python. httpit is a high-performance static file server built as a Python C extension, offering exceptional speed and efficiency.
pip install httpitServe files from the current directory on port 8000:
httpitServe files from a specific directory:
httpit /path/to/filesServe on a custom port:
httpit 8080Combine directory and port:
httpit /path/to/files 8080- π Blazing Fast - Built in C with zero-copy sendfile() support
- πͺΆ Lightweight - Minimal memory footprint and dependencies
- π§ Easy to Use - Simple command-line interface and Python API
- π Directory Listing - Browse directories with built-in HTML interface
- π Security - Basic authentication and access control support
- π Modern Standards - HTTP/1.1, IPv6, Keep-Alive, Range requests
- π Production Ready - Access logging, daemon mode, custom MIME types
# Serve current directory on port 8000 (default)
httpit
# Serve on specific port
httpit 8080
# Serve specific directory
httpit /var/www/html
# Serve specific directory on specific port
httpit /var/www/html 8080# Enable debug output
httpit -d
# Disable directory listing
httpit -F
# Enable access logging
httpit -l access.log
# Bind to specific IP
httpit -i 192.168.1.100
# Enable CORS headers
httpit -C
# Custom index file
httpit -I index.php
# Set connection timeout (seconds)
httpit -t 30
# Set maximum connections
httpit -c 100
# Run in background (daemon mode)
httpit -D
# Enable basic authentication
httpit -a username:password
# Serve specific virtual host
httpit -n www.example.com
# Custom mime types file
httpit -m /etc/mime.types# Production server with logging, authentication, and custom settings
httpit /var/www/html 443 \
-D \
-l /var/log/httpit/access.log \
-a admin:secure_password \
-F \
-t 60 \
-c 1000from httpit import HTTPServer
# Create and start server
server = HTTPServer(port=8080, root="/var/www/html")
server.start()
# Check if running
if server.is_running():
print("Server is running")
# Stop server
server.stop()from httpit import HTTPServer
with HTTPServer(port=8080) as server:
print(f"Serving at http://localhost:{server.port}")
input("Press Enter to stop...")from httpit import HTTPServer
server = HTTPServer(
port=8080,
root="/var/www/html",
host="www.example.com", # Virtual host
bind_ip="0.0.0.0", # Bind address
debug=True, # Debug output
no_listing=True, # Disable directory listing
auth="user:pass", # Basic auth
log="access.log", # Access log
cors="*", # CORS headers
timeout=60, # Connection timeout
max_connections=1000, # Max concurrent connections
index="index.php" # Index file
)
server.start()import threading
from httpit import HTTPServer
server = HTTPServer(port=8080)
# Start in background thread
thread = threading.Thread(target=server.serve_forever)
thread.daemon = True
thread.start()
# Your application continues running
# ...
# Stop when done
server.stop()httpit is designed for maximum performance:
- Zero-copy file serving using sendfile() system call
- Minimal memory allocations during request handling
- Efficient event loop with epoll/kqueue support
- Smart caching for directory listings and file metadata
Benchmark results show httpit can serve static files 2-5x faster than traditional Python web servers like http.server or SimpleHTTPServer.
- Static file serving - Websites, documentation, downloads
- Development server - Quick testing and prototyping
- Media streaming - Video/audio files with range support
- File sharing - Simple LAN file server
- CDN origin - Backend for content delivery networks
- Docker containers - Minimal footprint for containerized apps
| Feature | httpit | http.server | nginx | Apache |
|---|---|---|---|---|
| Performance | βββββ | ββ | βββββ | ββββ |
| Ease of Use | βββββ | βββββ | βββ | ββ |
| Memory Usage | βββββ | βββ | ββββ | βββ |
| Features | βββ | ββ | βββββ | βββββ |
| Python Integration | βββββ | βββββ | β | β |
- httpit is designed for serving static files only
- Always use
-Fflag to disable directory listing in production - Use authentication (
-a) for sensitive content - Run as non-root user when possible
- Consider using a reverse proxy for HTTPS in production
If you see "Port already in use" error:
# Find process using the port
lsof -i :8000
# Or force kill any httpit processes
pkill -f httpitIf serving from system directories:
# Use sudo (not recommended)
sudo httpit /etc 8080
# Better: copy files to user directory
cp -r /etc/myapp ~/myapp
httpit ~/myappRun with debug flag to see errors:
httpit -dhttpit is a high-performance HTTP server for Python. For feature requests and issues, submit PRs to the httpit repository or visit https://httpit.rodmena.co.uk
GNU General Public License v2.0 (GPLv2)
- httpit is developed and maintained by RODMENA LIMITED
- High-performance C-based HTTP server with Python integration
- Visit https://httpit.rodmena.co.uk for documentation and support
RODMENA LIMITED specializes in high-performance software solutions and web technologies. Visit us at https://rodmena.co.uk for more information about our services and products.
