Name | localtunnel-py JSON |
Version |
0.1.0
JSON |
| download |
home_page | https://github.com/gweidart/localtunnel |
Summary | Python port of the localtunnel.me Client | Expose localhost to the world! |
upload_time | 2024-11-17 11:25:46 |
maintainer | None |
docs_url | None |
author | gweidart |
requires_python | >=3.12 |
license | MIT License Copyright (c) 2024 GweiDart Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
localtunnel
tunnel
proxy
local server
port forwarding
subdomain
networking
http proxy
python client
cli tool
remote access
webhooks
cloud proxy
dynamic dns
ngrok alternative
localhost
secure tunnel
public url
developer tools
devops
system administration
network utilities
web server
firewalls
python library
python proxy
port tunneling
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# LocalTunnel Python Client
[![PyPI version](https://badge.fury.io/py/localtunnel.svg)](https://pypi.org/project/localtunnel/)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![Python Versions](https://img.shields.io/pypi/pyversions/localtunnel.svg)](https://pypi.org/project/localtunnel/)
Python port of the Localtunnel Client
Expose your localhost to the π for easy testing and sharing:
- π·π»ββοΈ Actively maintained
A Python client for [LocalTunnel](https://localtunnel.github.io/www/), enabling developers to expose their local servers to the internet with minimal setup. Designed for ease of use, flexibility, and lightweight integration, this library supports both CLI and programmatic APIs.
---
## Overview
LocalTunnel provides a simple way to make a local development server accessible to anyone on the internet. Unlike similar tools like Ngrok, this library is lightweight, open-source, and Python-native, making it perfect for developers who prefer seamless integration into their Python projects.
---
## Installation
Install using a package manager π¦:
### via `pip`
```bash
pip install localtunnel
```
### via `uv`
```bash
uv add localtunnel
```
### via `poetry`
```bash
poetry add Localtunnel
```
For contributors or advanced users, clone the repository and install in editable mode:
```bash
git clone https://github.com/gweidart/localtunnel.git
cd localtunnel
pip install -e .
```
---
## Features
- **Expose Local Servers Effortlessly**:
- Quickly share your local development server with a public URL.
- Perfect for testing webhooks, sharing progress with team members, or debugging remotely.
- **Custom Subdomains**:
- Use a custom subdomain to make your server URL more predictable and user-friendly.
- Example: `https://my-custom-subdomain.loca.lt`
- **Robust Retry Mechanisms**:
- Ensure tunnel connections are resilient with customizable retry strategies, including exponential backoff.
- **Monitoring and Lifecycle Management**:
- Built-in support for monitoring tunnels to handle unexpected disruptions.
- Automatically recover or notify when a tunnel goes offline.
- **Flexible Header Transformations**:
- Modify request headers dynamically using `HeaderTransformer`.
- **Lightweight CLI Tool**:
- A simple command-line interface for quick setup and deployment.
- **Seamless Integration**:
- Import the library directly into your Python project and manage tunnels programmatically.
- **Extensive Logging**:
- Fully customizable logging via [Loguru](https://loguru.readthedocs.io/).
---
## Quick Start
### Programmatic API
Hereβs how to expose a local server programmatically:
```python
import asyncio
from localtunnel.tunnel_manager import TunnelManager
async def main():
manager = TunnelManager()
manager.add_tunnel(port=8000, subdomain="my-subdomain")
try:
await manager.open_all()
for tunnel in manager.tunnels:
print(f"Tunnel open at URL: {tunnel.get_tunnel_url()}")
# Keep running
await asyncio.Event().wait()
finally:
await manager.close_all()
asyncio.run(main())
```
---
### CLI Usage
Expose a local server directly from the command line:
```bash
lt --port 3002 -s my-subdomain
```
Available arguments:
| Argument | Description |
| ----------------- | -------------------------------------------------------------------------- |
| `-p, --port` | Local port to expose via the tunnel (required). |
| `-s, --subdomain` | Optional subdomain for the tunnel. |
| `-t, --host` | LocalTunnel server URL (default: `https://localtunnel.me`). |
| `-m, --monitor` | Enable monitoring of the tunnel. |
| `-l, --log-level` | Set the log level (e.g., `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL`). |
---
## Advanced Usage
### Create a new localtunnel
```python
import asyncio
from localtunnel.tunnel_manager import TunnelManager
async def main():
manager = TunnelManager()
manager.add_tunnel(port=8000, subdomain="my-subdomain")
try:
await manager.open_all()
for tunnel in manager.tunnels:
print(f"Tunnel open at URL: {tunnel.get_tunnel_url()}")
# Keep running
await asyncio.Event().wait()
finally:
await manager.close_all()
asyncio.run(main())
```
```
```
### Custom Header Transformations
Modify headers dynamically using `HeaderTransformer`:
```python
from localtunnel.header_transformer import HeaderTransformerFactory
transformer = HeaderTransformerFactory.create_transformer(
transformer_type="host", host="my-custom-host"
)
headers = {"Authorization": "Bearer token"}
transformed_headers = transformer.transform(headers)
print(transformed_headers)
```
---
### Retry Strategies
Implement robust retry mechanisms for tunnel connections:
```python
from localtunnel.utils import ExponentialBackoffRetryTemplate
retry_strategy = ExponentialBackoffRetryTemplate(base_delay=1.0, max_delay=10.0)
retry_strategy.retry(some_function, retries=5)
```
---
### Managing Multiple Tunnels
Use `TunnelManager` to handle multiple tunnels seamlessly:
```python
from localtunnel.tunnel_manager import TunnelManager
manager = TunnelManager()
manager.add_tunnel(port=8000, subdomain="app1")
manager.add_tunnel(port=8001, subdomain="app2")
await manager.open_all()
```
---
## Troubleshooting
- **Issue**: Tunnel connection drops frequently.
- **Solution**: Enable monitoring with `TunnelManager`.
- **Issue**: Logs are too verbose.
- **Solution**: Customize log levels using `--log-level` in the CLI or `logger.add()` in code.
- **Issue**: Custom subdomain not working.
- **Solution**: Ensure the subdomain is available and correctly passed to `add_tunnel()`.
---
## Contributing
We welcome contributions! Here's how you can get involved:
1. Fork the repository.
2. Create a new branch for your feature or bugfix.
3. Submit a pull request with a detailed description.
---
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
---
## Links and Acknowledgments
- [Source Code](https://github.com/gweidart/localtunnel)
- [Issue Tracker](https://github.com/gweidart/localtunnel/issues)
- [Documentation](https://github.com/gweidart/localtunnel#readme)
Raw data
{
"_id": null,
"home_page": "https://github.com/gweidart/localtunnel",
"name": "localtunnel-py",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": null,
"keywords": "localtunnel, tunnel, proxy, local server, port forwarding, subdomain, networking, http proxy, python client, cli tool, remote access, webhooks, cloud proxy, dynamic DNS, ngrok alternative, localhost, secure tunnel, public URL, developer tools, devops, system administration, network utilities, web server, firewalls, python library, python proxy, port tunneling",
"author": "gweidart",
"author_email": "gweidart <btnewcomer@pm.me>",
"download_url": "https://files.pythonhosted.org/packages/de/6d/e694a980be9d3332802a029771084dce043a9764ec0d7d0a838484226f69/localtunnel_py-0.1.0.tar.gz",
"platform": null,
"description": "# LocalTunnel Python Client\n\n[![PyPI version](https://badge.fury.io/py/localtunnel.svg)](https://pypi.org/project/localtunnel/)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n[![Python Versions](https://img.shields.io/pypi/pyversions/localtunnel.svg)](https://pypi.org/project/localtunnel/)\n\nPython port of the Localtunnel Client\n\nExpose your localhost to the \ud83c\udf0e for easy testing and sharing:\n\n- \ud83d\udc77\ud83c\udffb\u200d\u2642\ufe0f Actively maintained\n\nA Python client for [LocalTunnel](https://localtunnel.github.io/www/), enabling developers to expose their local servers to the internet with minimal setup. Designed for ease of use, flexibility, and lightweight integration, this library supports both CLI and programmatic APIs.\n\n---\n\n## Overview\n\nLocalTunnel provides a simple way to make a local development server accessible to anyone on the internet. Unlike similar tools like Ngrok, this library is lightweight, open-source, and Python-native, making it perfect for developers who prefer seamless integration into their Python projects.\n\n---\n\n## Installation\n\nInstall using a package manager \ud83d\udce6:\n\n### via `pip`\n\n```bash\npip install localtunnel\n```\n\n### via `uv`\n\n```bash\nuv add localtunnel\n```\n\n### via `poetry`\n\n```bash\npoetry add Localtunnel\n```\n\nFor contributors or advanced users, clone the repository and install in editable mode:\n\n```bash\ngit clone https://github.com/gweidart/localtunnel.git\ncd localtunnel\npip install -e .\n```\n\n---\n\n## Features\n\n- **Expose Local Servers Effortlessly**:\n\n - Quickly share your local development server with a public URL.\n - Perfect for testing webhooks, sharing progress with team members, or debugging remotely.\n\n- **Custom Subdomains**:\n\n - Use a custom subdomain to make your server URL more predictable and user-friendly.\n - Example: `https://my-custom-subdomain.loca.lt`\n\n- **Robust Retry Mechanisms**:\n\n - Ensure tunnel connections are resilient with customizable retry strategies, including exponential backoff.\n\n- **Monitoring and Lifecycle Management**:\n\n - Built-in support for monitoring tunnels to handle unexpected disruptions.\n - Automatically recover or notify when a tunnel goes offline.\n\n- **Flexible Header Transformations**:\n\n - Modify request headers dynamically using `HeaderTransformer`.\n\n- **Lightweight CLI Tool**:\n\n - A simple command-line interface for quick setup and deployment.\n\n- **Seamless Integration**:\n\n - Import the library directly into your Python project and manage tunnels programmatically.\n\n- **Extensive Logging**:\n - Fully customizable logging via [Loguru](https://loguru.readthedocs.io/).\n\n---\n\n## Quick Start\n\n### Programmatic API\n\nHere\u2019s how to expose a local server programmatically:\n\n```python\nimport asyncio\nfrom localtunnel.tunnel_manager import TunnelManager\n\nasync def main():\n manager = TunnelManager()\n manager.add_tunnel(port=8000, subdomain=\"my-subdomain\")\n\n try:\n await manager.open_all()\n for tunnel in manager.tunnels:\n print(f\"Tunnel open at URL: {tunnel.get_tunnel_url()}\")\n\n # Keep running\n await asyncio.Event().wait()\n finally:\n await manager.close_all()\n\nasyncio.run(main())\n```\n\n---\n\n### CLI Usage\n\nExpose a local server directly from the command line:\n\n```bash\nlt --port 3002 -s my-subdomain\n```\n\nAvailable arguments:\n\n| Argument | Description |\n| ----------------- | -------------------------------------------------------------------------- |\n| `-p, --port` | Local port to expose via the tunnel (required). |\n| `-s, --subdomain` | Optional subdomain for the tunnel. |\n| `-t, --host` | LocalTunnel server URL (default: `https://localtunnel.me`). |\n| `-m, --monitor` | Enable monitoring of the tunnel. |\n| `-l, --log-level` | Set the log level (e.g., `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL`). |\n\n---\n\n## Advanced Usage\n\n### Create a new localtunnel\n\n```python\nimport asyncio\nfrom localtunnel.tunnel_manager import TunnelManager\n\nasync def main():\n manager = TunnelManager()\n manager.add_tunnel(port=8000, subdomain=\"my-subdomain\")\n\n try:\n await manager.open_all()\n for tunnel in manager.tunnels:\n print(f\"Tunnel open at URL: {tunnel.get_tunnel_url()}\")\n\n # Keep running\n await asyncio.Event().wait()\n finally:\n await manager.close_all()\n\nasyncio.run(main())\n\n```\n\n```\n\n```\n\n### Custom Header Transformations\n\nModify headers dynamically using `HeaderTransformer`:\n\n```python\nfrom localtunnel.header_transformer import HeaderTransformerFactory\n\ntransformer = HeaderTransformerFactory.create_transformer(\n transformer_type=\"host\", host=\"my-custom-host\"\n)\nheaders = {\"Authorization\": \"Bearer token\"}\ntransformed_headers = transformer.transform(headers)\nprint(transformed_headers)\n```\n\n---\n\n### Retry Strategies\n\nImplement robust retry mechanisms for tunnel connections:\n\n```python\nfrom localtunnel.utils import ExponentialBackoffRetryTemplate\n\nretry_strategy = ExponentialBackoffRetryTemplate(base_delay=1.0, max_delay=10.0)\nretry_strategy.retry(some_function, retries=5)\n```\n\n---\n\n### Managing Multiple Tunnels\n\nUse `TunnelManager` to handle multiple tunnels seamlessly:\n\n```python\nfrom localtunnel.tunnel_manager import TunnelManager\n\nmanager = TunnelManager()\nmanager.add_tunnel(port=8000, subdomain=\"app1\")\nmanager.add_tunnel(port=8001, subdomain=\"app2\")\nawait manager.open_all()\n```\n\n---\n\n## Troubleshooting\n\n- **Issue**: Tunnel connection drops frequently.\n\n - **Solution**: Enable monitoring with `TunnelManager`.\n\n- **Issue**: Logs are too verbose.\n\n - **Solution**: Customize log levels using `--log-level` in the CLI or `logger.add()` in code.\n\n- **Issue**: Custom subdomain not working.\n - **Solution**: Ensure the subdomain is available and correctly passed to `add_tunnel()`.\n\n---\n\n## Contributing\n\nWe welcome contributions! Here's how you can get involved:\n\n1. Fork the repository.\n2. Create a new branch for your feature or bugfix.\n3. Submit a pull request with a detailed description.\n\n---\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n---\n\n## Links and Acknowledgments\n\n- [Source Code](https://github.com/gweidart/localtunnel)\n- [Issue Tracker](https://github.com/gweidart/localtunnel/issues)\n- [Documentation](https://github.com/gweidart/localtunnel#readme)\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2024 GweiDart Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "Python port of the localtunnel.me Client | Expose localhost to the world!",
"version": "0.1.0",
"project_urls": {
"Changelog": "https://github.com/gweidart/localtunnel/blob/master/CHANGELOG.md",
"Documentation": "https://github.com/gweidart/localtunnel/README.md",
"Homepage": "https://github.com/gweidart/localtunnel.git",
"Issues": "https://github.com/gweidart/localtunnel/issues",
"Repository": "https://github.com/gweidart/localtunnel.git"
},
"split_keywords": [
"localtunnel",
" tunnel",
" proxy",
" local server",
" port forwarding",
" subdomain",
" networking",
" http proxy",
" python client",
" cli tool",
" remote access",
" webhooks",
" cloud proxy",
" dynamic dns",
" ngrok alternative",
" localhost",
" secure tunnel",
" public url",
" developer tools",
" devops",
" system administration",
" network utilities",
" web server",
" firewalls",
" python library",
" python proxy",
" port tunneling"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a89662f977513e13e853dc497c9a72cbd736a9c4a5e59abc7852ec16e4cd2c22",
"md5": "25fbf303bef861cb1571bc7e343bf2c0",
"sha256": "2277e705dcd7e3dade965fdce5fc57217598f8941f965625dec3b20b67cd10e5"
},
"downloads": -1,
"filename": "localtunnel_py-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "25fbf303bef861cb1571bc7e343bf2c0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 14799,
"upload_time": "2024-11-17T11:25:44",
"upload_time_iso_8601": "2024-11-17T11:25:44.841035Z",
"url": "https://files.pythonhosted.org/packages/a8/96/62f977513e13e853dc497c9a72cbd736a9c4a5e59abc7852ec16e4cd2c22/localtunnel_py-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "de6de694a980be9d3332802a029771084dce043a9764ec0d7d0a838484226f69",
"md5": "22910bb300f505725f74c722b756619f",
"sha256": "b32c252615755ccaf9999384614d7e2ee62e034067882425a3f6598837386ea2"
},
"downloads": -1,
"filename": "localtunnel_py-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "22910bb300f505725f74c722b756619f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 15493,
"upload_time": "2024-11-17T11:25:46",
"upload_time_iso_8601": "2024-11-17T11:25:46.030934Z",
"url": "https://files.pythonhosted.org/packages/de/6d/e694a980be9d3332802a029771084dce043a9764ec0d7d0a838484226f69/localtunnel_py-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-17 11:25:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "gweidart",
"github_project": "localtunnel",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "localtunnel-py"
}