Turn any machine into a public server instantly with automated zero-config tunnels.
Project description
GlobalHost 🛰️
Turn any machine running your code into a publicly accessible, secure SaaS backend instantly. No localhost, no router configuration, and zero cloud deployment setup needed during development.
Features
- Zero-Config Public Ingress: Automatically spawns a secure, temporary public HTTPS tunnel (
.trycloudflare.com) on startup. - Framework Agnostic: Works flawlessly out-of-the-box with FastAPI, Django, Flask, Streamlit, or raw Python scripts.
- Self-Contained & Lightweight: Auto-provisions the exact native binary for your OS (Mac/Win/Lin) on the fly. No
brew,apt, or manual downloads required, and keeps the pip package tiny. - Zero Dependencies: The core package uses only Python's standard library. No external packages required for tunneling.
- Bulletproof Process Management: Automatic signal handling (Ctrl+C, Ctrl+Z, terminal close) ensures zero zombie processes and instant port cleanup.
- Background Launch Mode: Run your app in the background while maintaining full control over the tunnel lifecycle.
Architecture
[ Any PC Running Your Code ] ──(Outbound Tunnel)──> [ Global Edge Network ] ──> [ Public Internet URL ]
Quick Start
1. Installation
pip install globalhost
2. Basic Usage (Background Mode)
Drop this into your project entrypoint. This automatically boots the tunnel and wraps your web framework in the background.
import time
from globalhost import GlobalHostApp
from fastapi import FastAPI
app = FastAPI()
@app.get("/my-algo")
def run_algo():
return {"status": "Your golden algo is live globally!"}
if __name__ == "__main__":
host = GlobalHostApp()
# Launch tunnel and server in background
if host.bg_launch(framework="fastapi", app="main:app", port=8000):
print(f"Public URL: {host.get_url()}")
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
host.stop()
3. Programmatic Usage (Advanced)
Need to inject the live public URL into a database, webhook, or frontend config at runtime? Use the programmatic API:
from globalhost import GlobalHostApp
host = GlobalHostApp()
# Start the tunnel and server in background
if host.bg_launch(framework="fastapi", app="main:app", port=9000):
# Get the public endpoint string
public_endpoint = host.get_url()
print(f"🔗 Live Hyperlink: {public_endpoint}")
# Inject into your config, database, or webhook
# register_webhook(public_endpoint)
# Keep alive
import time
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
host.stop()
How It Works Under the Hood
- OS Detection: On execution, the module identifies the hosting machine's operating system and architecture.
- Auto-Provisioning: It silently downloads and caches the exact lightweight network binary required for that specific system.
- Reverse Tunnel Routing: It executes the binary to establish a secure outbound connection to a global edge router, bypassing local firewalls and printing your public production-ready endpoint straight to the console.
- Process Isolation: Framework servers run in isolated subprocesses with their own environment variables, preventing conflicts with your main application.
- Signal Handling: The package registers OS-level signal handlers to ensure graceful shutdown on Ctrl+C, Ctrl+Z, or terminal close, preventing zombie processes.
Examples
Ready-to-run implementations are available in the examples/ directory:
- FastAPI:
examples/fastapi/01_json_api.py&02_webpage.py - Django:
examples/django/01_json_api.py&02_webpage.py - Flask:
examples/flask/01_json_api.py&02_webpage.py - Streamlit:
examples/streamlit/01_json_api.py&02_webpage.py
Run any example:
python examples/fastapi/01_json_api.py
Author
Joel Opoku 📧 joelclouds@gmail.com 🌐 joelclouds.pythonanywhere.com 🐙 github.com/joelclouds/globalhost
License
Distributed under the MIT License. See LICENSE for more information.
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 globalhost-0.2.0.tar.gz.
File metadata
- Download URL: globalhost-0.2.0.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9c1d03b45bc4ced56d2a3967a7f7778dcfee76ad734962916f0102ef001741e
|
|
| MD5 |
f872ec2ce7f310f440559f90582f2288
|
|
| BLAKE2b-256 |
235184b182db2e2b7e0ee62dc865e79d14ec9073330483556d6d1854f5614923
|
File details
Details for the file globalhost-0.2.0-py3-none-any.whl.
File metadata
- Download URL: globalhost-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
274496ab37d59639fc34e3598fc5652d4cd4a5538a1f31f3d29a006ecd3fe479
|
|
| MD5 |
a00674c3ef5d857f79a1bc04e18f3489
|
|
| BLAKE2b-256 |
915a212a951df8232936ac3dc26ea6f9ec99825c96c079e1da1537e9755c0f07
|