Beta Feature: Prime Tunnel is currently in beta with limited availability.
What is Prime Tunnel?
Prime Tunnel creates secure, public URLs for services running on your local machine. You start a local server, create a tunnel, and get an HTTPS URL that anyone can access.
Common use cases:
- Expose a local development server to the internet
- Receive webhooks from external services during development
- Share a work-in-progress app with teammates
Complete Example
Here’s a full working example: start a local HTTP server and expose it to the internet.
1. Start a local server
# Create a simple HTML file
echo '<h1>Hello from Prime Tunnel!</h1>' > index.html
# Start Python's built-in HTTP server on port 8000
python -m http.server 8000
2. Create a tunnel (in another terminal)
import asyncio
from prime_tunnel import Tunnel
async def main():
tunnel = Tunnel(local_port=8000)
await tunnel.start()
print(f"Public URL: {tunnel.url}")
print("Press Ctrl+C to stop")
# Keep running until interrupted
try:
while True:
await asyncio.sleep(1)
except KeyboardInterrupt:
pass
finally:
await tunnel.stop()
asyncio.run(main())
3. Access your server
Open the printed URL (e.g., https://t-abc123.tunnel.pinfra.io) in any browser. Your local server is now accessible from anywhere.
Context Manager
For automatic cleanup, use the async context manager:
async with Tunnel(local_port=8000) as tunnel:
print(f"URL: {tunnel.url}")
# Tunnel is active here
# Tunnel automatically stopped
Tunnel Properties
tunnel = Tunnel(local_port=8000)
await tunnel.start()
tunnel.tunnel_id # "t-abc123def456"
tunnel.url # "https://t-abc123def456.tunnel.pinfra.io"
CLI Commands
# Start a tunnel
prime tunnel start --port 8000
# List active tunnels
prime tunnel list
# Stop a tunnel
prime tunnel stop t-abc123def456