Expose your local FastAPI, NiceGUI, or development servers remotely — easily, reliably, and for free.
Project description
remote-local
Expose your local FastAPI, NiceGUI, or development servers remotely — easily, reliably, and for free.
remote-local is a simple and robust middleware that automatically creates a public tunnel for your local server using ngrok (and more in the future).
It handles session cleanup, hot reloads, and retries automatically — no manual setup required.
Features
- 🌍 Expose your local server remotely with one line of code.
- ⚡ Fully compatible with FastAPI, NiceGUI, or any ASGI app.
- 🔄 Handles hot reloads and session recovery automatically.
- 🔒 No external configuration required — works with free ngrok accounts.
- 🛠️ Designed for development, testing, and remote integrations.
Installation
pip install remote-local
Quick Usage
from nicegui import app, ui
from remote_local import NgrokMiddleware
NgrokMiddleware(app, port=8080)
@ui.page('/')
async def main_page():
ui.label('Hello World')
ui.run(port=8080, reload=True)
✅ That's it! Your local server is now publicly accessible through a secure URL.
By default, a /server-info endpoint is also created, showing the current public URL and server status.
Environment Variable: PUBLIC_URL
If your server is already running with a public URL (for example, in a production deployment), you can set the PUBLIC_URL environment variable. When PUBLIC_URL is set, the middleware will skip starting ngrok and use the provided URL as the public-facing address for your app.
- If
PUBLIC_URLis set, ngrok will not be started and the middleware will simply use this value. - If
PUBLIC_URLis not set, the middleware will start ngrok and set the public URL automatically.
Example:
export PUBLIC_URL=https://your-production-url.example.com
Configuration Options
You can customize the middleware:
NgrokMiddleware(
app,
port=8080,
max_wait_seconds=60, # how long to retry if ngrok fails initially
fallback_to_localhost=False, # fallback to localhost if ngrok fails
expose_server_info=True, # create a /server-info endpoint
)
License
This project is licensed under the MIT License.
Future Plans
- Support for other tunnels (Cloudflared, Localhost.run, etc.)
- More flexible server info APIs
- Auto-detection of multiple servers
Author
Made with ❤️ by Pablo Schaffner
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file remote_local-0.0.2.tar.gz.
File metadata
- Download URL: remote_local-0.0.2.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f14eee51ba56763949de5a61866fc728623b15e31a90a39699d52c146068234d
|
|
| MD5 |
b625428cc195ee192974031e2c190447
|
|
| BLAKE2b-256 |
ddf2dd48642c2145d5324d65221d1c5cb29b6f8beb82bc01efba50de2948a26a
|
File details
Details for the file remote_local-0.0.2-py3-none-any.whl.
File metadata
- Download URL: remote_local-0.0.2-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a032ba7d5ca2b7bb4905f81b054ab68ae01bb5f2c391e4f62433fe652a806927
|
|
| MD5 |
456cbfe8c2dae0d7e0ed6921d30bba84
|
|
| BLAKE2b-256 |
6c09a4063cce60848841618c2768cbdd47ea89449dc0bb5faa2ab0c52a971d22
|