Skip to main content

Framework-specific tunnel commands — uvicorn-mekong, flask-mekong, django-mekong and more

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mekong_tunnel-2.0.1.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mekong_tunnel-2.0.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file mekong_tunnel-2.0.1.tar.gz.

File metadata

  • Download URL: mekong_tunnel-2.0.1.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for mekong_tunnel-2.0.1.tar.gz
Algorithm Hash digest
SHA256 836f1b37a6d239aee2dc8528a5e3722e90f21f2534b8f02398525795711c3173
MD5 6140ec077f99b330fca723a9b35fb6d9
BLAKE2b-256 35ce95756c5368e090d6b9018e574755f0926e7c92d73aab990b4a54041e17ba

See more details on using hashes here.

File details

Details for the file mekong_tunnel-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: mekong_tunnel-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for mekong_tunnel-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4320f1d2ae4231ad05ee00085ba9e70cf3874e63bdd50a8c133f081ed1911759
MD5 8654c8102ed0ffcec430a57889155263
BLAKE2b-256 f902dffe8d088f769bcbfbfe04af82adf073af3c3e948d13355977da77bb4a5c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page