Skip to main content

mekong-tunnel

Expose your Python dev server to the internet in one command. Works with FastAPI, Flask, Django, Gunicorn, Uvicorn, Hypercorn, and Granian.

PyPI version Python versions License: MIT


How it works

mekong-tunnel installs framework-specific commands that start your dev server and open a public tunnel via mekongtunnel.dev — all in a single command.

uvicorn-mekong main:app --reload
 uvicorn-mekong  cmd: uvicorn main:app --reload  port: 8000  mode: tunnel

[uvicorn] INFO:     Uvicorn running on http://127.0.0.1:8000
✔  uvicorn is up on port 8000.
[tunnel]  ✔  Tunnel is live!
[tunnel]     URL  https://happy-tiger-a1b2c3d4.mekongtunnel.dev

╔═══════════════════════════════════════════════════════════════╗
║  Public URL: https://happy-tiger-a1b2c3d4.mekongtunnel.dev   ║
╚═══════════════════════════════════════════════════════════════╝

Installation

pip install mekong-tunnel

Requires the mekong binary — install it separately:

# macOS / Linux (auto-detect arch)
curl -fsSL https://github.com/MuyleangIng/MekongTunnel/releases/latest/download/mekong-$(uname -s | tr A-Z a-z)-$(uname -m) \
  -o ~/.local/bin/mekong && chmod +x ~/.local/bin/mekong

# Windows — download from:
# https://github.com/MuyleangIng/MekongTunnel/releases/latest

Commands

Command Framework Default port
uvicorn-mekong Uvicorn / FastAPI 8000
fastapi-mekong FastAPI (alias for uvicorn) 8000
flask-mekong Flask 5000
gunicorn-mekong Gunicorn 8000
django-mekong Django 8000
hypercorn-mekong Hypercorn 8000
granian-mekong Granian 8000

Modes

Each command supports three modes:

Flag Mode What happens
(none) tunnel Start server + open public tunnel, print URL
--local local Start server only, open http://localhost:{port} in browser
--domain domain Start server + tunnel, open public URL in browser

Usage

FastAPI / Uvicorn

# Default: start server + tunnel, print public URL
uvicorn-mekong main:app

# With hot-reload and custom port
uvicorn-mekong main:app --reload --port 8080

# Open localhost in browser (no tunnel)
uvicorn-mekong main:app --local

# Open public URL in browser automatically
uvicorn-mekong main:app --domain

# Tunnel with 2-hour expiry
uvicorn-mekong main:app --expire 2h

# fastapi-mekong is identical to uvicorn-mekong
fastapi-mekong main:app --reload --domain

Flask

flask-mekong run                        # port 5000 + tunnel
flask-mekong run --port 5001            # custom port
flask-mekong run --local                # localhost only, open browser
flask-mekong run --domain               # tunnel + open public URL
flask-mekong run --expire 1d            # expires in 1 day

Django

django-mekong runserver                 # port 8000 + tunnel
django-mekong runserver 8080            # custom port
django-mekong runserver 0.0.0.0:8000   # bind all interfaces
django-mekong runserver --local         # localhost only, open browser
django-mekong runserver --domain        # tunnel + open public URL

Gunicorn

gunicorn-mekong app:app                        # port 8000 + tunnel
gunicorn-mekong app:app --bind 0.0.0.0:8080    # custom port
gunicorn-mekong app:app -w 4                   # 4 workers + tunnel
gunicorn-mekong app:app --domain               # tunnel + open public URL

Hypercorn

hypercorn-mekong main:app                      # port 8000 + tunnel
hypercorn-mekong main:app --bind 0.0.0.0:8080  # custom port
hypercorn-mekong main:app --domain             # tunnel + open public URL

Granian

granian-mekong main:app                        # port 8000 + tunnel
granian-mekong main:app --port 8080            # custom port
granian-mekong main:app --domain               # tunnel + open public URL

All mekong-tunnel flags

These flags are consumed by mekong-tunnel and not forwarded to your framework:

Flag Description
--local No tunnel — open localhost in browser
--domain Tunnel + open public URL in browser
--expire <val> Tunnel expiry: 30m, 2h, 1d, 1w
--no-qr Suppress QR code in terminal
--daemon Run tunnel in background
--help, -h Show help

All other flags are forwarded verbatim to your framework.


Quick test (FastAPI)

pip install fastapi uvicorn mekong-tunnel

cat > main.py << 'EOF'
from fastapi import FastAPI
app = FastAPI()

@app.get("/")
def root():
    return {"message": "Hello from Mekong Tunnel!"}
EOF

uvicorn-mekong main:app --reload

How it works internally

  1. Start your server as a subprocess
  2. Poll the port until it accepts connections (30 s timeout)
  3. Spawn mekong tunnel to the detected port
  4. Stream both outputs to your terminal
  5. On URL detected — print banner (and open browser if --domain)
  6. Clean shutdown on Ctrl+C — stops both processes

Requirements

  • Python 3.8+
  • mekong binary on PATH (download)
  • No other Python dependencies

License

MIT © Ing Muyleang — KhmerStack

Metadata

Release files for mekong-tunnel 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mekong-tunnel 2.0.1
File Size Uploaded Provenance Actions
mekong_tunnel-2.0.1.tar.gz 11.0 kB Without provenance Details for mekong_tunnel-2.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mekong-tunnel 2.0.1
File Interpreter ABI Platform Actions
mekong_tunnel-2.0.1-py3-none-any.whl Python 3 none any Details for mekong_tunnel-2.0.1-py3-none-any.whl

Total release size: 21.6 kB

Release files / mekong_tunnel-2.0.1.tar.gz

Download URL mekong_tunnel-2.0.1.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
836f1b37a6d239aee2dc8528a5e3722e90f21f2534b8f02398525795711c3173
BLAKE2b-256 checksum
How to use checksums
35ce95756c5368e090d6b9018e574755f0926e7c92d73aab990b4a54041e17ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / mekong_tunnel-2.0.1-py3-none-any.whl

Download URL mekong_tunnel-2.0.1-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4320f1d2ae4231ad05ee00085ba9e70cf3874e63bdd50a8c133f081ed1911759
BLAKE2b-256 checksum
How to use checksums
f902dffe8d088f769bcbfbfe04af82adf073af3c3e948d13355977da77bb4a5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for mekong-tunnel 2.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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