Skip to main content

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_URL is set, ngrok will not be started and the middleware will simply use this value.
  • If PUBLIC_URL is 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


Download files

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

Source Distribution

remote_local-0.0.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

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

remote_local-0.0.1-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file remote_local-0.0.1.tar.gz.

File metadata

  • Download URL: remote_local-0.0.1.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

Hashes for remote_local-0.0.1.tar.gz
Algorithm Hash digest
SHA256 17cd9f7e14db41ab1746a53f07292c27fca44322a9b8dd755fc46d34a7547212
MD5 1ca6785ebd4ce2c05acb9676dcd7c9ee
BLAKE2b-256 414ef8fad054a8716d7db48783c0314165404f75ad398c7cc93b3d0c94cf6885

See more details on using hashes here.

File details

Details for the file remote_local-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: remote_local-0.0.1-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

Hashes for remote_local-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2b0734ba73ab85c64080889a75a39cc98631252ced27fc386919afc408ef3abc
MD5 a1de2ced9eebd763b46fb98dd14d6009
BLAKE2b-256 5978450736034f364bcf497728209d1788439d30813ff66c706c8faada78a528

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