Use mekong-uvicorn and mekong-gunicorn when you need direct control over your ASGI/WSGI server — without framework-specific wrappers.
Uvicorn (ASGI)
Uvicorn is the recommended ASGI server for FastAPI, Starlette, and other async apps.
Install
pip install mekong-tunnel uvicornUsage
# Same as: uvicorn myapp:app
mekong-uvicorn myapp:app
# With options
mekong-uvicorn myapp:app --host 0.0.0.0 --port 8000 --reload --workers 2Open in Browser
mekong-uvicorn myapp:app --reload --domainAll Uvicorn Options Pass Through
mekong-uvicorn myapp:app \
--host 0.0.0.0 \
--port 8000 \
--reload \
--reload-dir ./src \
--log-level info \
--ssl-keyfile ./key.pem \
--ssl-certfile ./cert.pem \
--workers 4Example: Raw ASGI App
# myapp.py
async def app(scope, receive, send):
if scope["type"] == "http":
await send({
"type": "http.response.start",
"status": 200,
"headers": [[b"content-type", b"application/json"]],
})
await send({
"type": "http.response.body",
"body": b'{"hello": "world"}',
})mekong-uvicorn myapp:app --domainGunicorn (WSGI)
Gunicorn is the standard production WSGI server for Flask, Django, and Pyramid.
Install
pip install mekong-tunnel gunicornUsage
# Same as: gunicorn myapp:app
mekong-gunicorn myapp:app
# With WSGI config
mekong-gunicorn myapp:application --workers 4 --bind 0.0.0.0:8000Open in Browser
mekong-gunicorn myapp:app --domainGunicorn Config File
# gunicorn.conf.py
bind = "0.0.0.0:8000"
workers = 4
worker_class = "sync"
timeout = 120
loglevel = "info"mekong-gunicorn myapp:app -c gunicorn.conf.py --domainGunicorn + Uvicorn Workers (ASGI via Gunicorn)
Use gunicorn as the process manager with uvicorn workers — the best setup for production:
pip install gunicorn uvicorn[standard]
mekong-gunicorn myapp:app \
--worker-class uvicorn.workers.UvicornWorker \
--workers 4 \
--bind 0.0.0.0:8000 \
--domainThis gives you gunicorn's worker management + uvicorn's async performance.
Django with Gunicorn
mekong-gunicorn myproject.wsgi:application \
--workers 4 \
--bind 0.0.0.0:8000 \
--domainFlask with Gunicorn
mekong-gunicorn "myapp:create_app()" \
--workers 2 \
--domainComparison
mekong-uvicorn | mekong-gunicorn | |
|---|---|---|
| Protocol | ASGI | WSGI |
| Best for | FastAPI, Starlette, async | Flask, Django, sync |
| Workers | Single/multi | Multi-process |
| Reload | --reload flag | Requires --reload (dev only) |
| Production | Yes (with --workers) | Yes |
Programmatic API
from mekong_tunnel import start_tunnel
import subprocess, sys
# Start tunnel
tunnel = start_tunnel(port=8000)
print("Tunnel URL:", tunnel.url)
# Start uvicorn manually
subprocess.run([
sys.executable, "-m", "uvicorn",
"myapp:app", "--host", "0.0.0.0", "--port", "8000", "--reload"
])Environment Variables
MEKONG_TOKEN=your_token mekong-uvicorn myapp:app --reload
MEKONG_TOKEN=your_token mekong-gunicorn myapp:app --workers 4