A high-performance WSGI server written in Zig. Run Python web applications (Flask, Django, etc.) with the speed of native code.
- Fast: Built on http.zig with 140K+ req/sec baseline
- PEP 3333 Compliant: Full WSGI specification support
- Multi-threaded: Configurable worker thread pool
- Virtual Environment Support: Automatically detects and activates Python virtual environments
- Simple CLI: Gunicorn-like command interface
- Zig 0.15.2+
- Python 3.11+ with development headers
# Debian/Ubuntu
sudo apt install python3-dev
# Fedora
sudo dnf install python3-devel
# macOS (with Homebrew)
brew install [email protected]
# Windows
# Install Python from python.org with "Development files" option# Clone the repository
git clone https://github.com/yourusername/zwsgi.git
cd zwsgi
# Build
zig build
# The executable will be at ./zig-out/bin/zwsgi# Basic usage
zwsgi myapp:application
# With options
zwsgi -b 0.0.0.0 -p 8080 -w 8 myapp.wsgi:application
# With virtual environment (auto-detected from VIRTUAL_ENV)
source venv/bin/activate
zwsgi myapp:application
# With additional Python path
zwsgi --pythonpath /path/to/myapp myapp.wsgi:application| Option | Description | Default |
|---|---|---|
-b, --bind ADDRESS |
Bind address | 127.0.0.1 |
-p, --port PORT |
Port number | 8000 |
-w, --workers N |
Number of worker threads | 4 |
--pythonpath PATH |
Additional Python path | - |
-h, --help |
Show help message | - |
# app.py
def application(environ, start_response):
status = '200 OK'
headers = [('Content-Type', 'text/plain')]
start_response(status, headers)
return [b'Hello, World!\n']zwsgi app:application# flask_app.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return 'Hello from Flask!'
application = appzwsgi flask_app:applicationzwsgi --pythonpath /path/to/django/project myproject.wsgi:application┌─────────────────────────────────────────────────────────┐
│ ZWSGI Server │
├─────────────────────────────────────────────────────────┤
│ ┌─────────────────────────────────────────────────┐ │
│ │ http.zig │ │
│ │ (HTTP parsing, thread pool) │ │
│ └─────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────┐ │
│ │ WSGI Handler │ │
│ │ (environ builder, start_response, iterator) │ │
│ └─────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────┐ │
│ │ Python C API Integration │ │
│ │ (GIL management, type conversion) │ │
│ └─────────────────────────────────────────────────┘ │
└──────────────────────────┼──────────────────────────────┘
▼
┌──────────────────┐
│ Python WSGI │
│ Application │
│ (Flask/Django) │
└──────────────────┘
# Build
zig build
# Run tests
zig build test
# Run with arguments
zig build run -- --pythonpath test_apps simple:applicationMIT