Skip to main content

Python library for creating SSH-based tunnels to expose local services, supporting providers such as serveo.net and localhost.run. It embraces modern Python syntax, asyncio, and context managers for a straightforward and user-friendly experience.

Project description

pyexpose

Documentation Status

pyexpose is a Python library designed to streamline the process of exposing local services to the internet using various SSH-based providers, such as serveo.net and localhost.run. With pyexpose, developers can effortlessly share their local services with remote collaborators or external systems, eliminating the need for manual configuration and exposing an abstraction layer for seamless integration.

Installation

Install the pyexpose package with pip:

$ pip install pyexpose

Or install the latest package directly from GitHub with the async extra:

$ pip install git+https://github.com/hari01584/pyexpose

Example Usage

import asyncio
import threading
from http.server import ThreadingHTTPServer
from http.server import SimpleHTTPRequestHandler

class MyHttpRequestHandler(SimpleHTTPRequestHandler):
    def end_headers(self):
        self.send_header('Access-Control-Allow-Origin', '*')
        SimpleHTTPRequestHandler.end_headers(self)

    def do_GET(self):
        self.send_response(200)
        self.send_header("Content-type", "text/html")
        self.end_headers()
        html = f"31"  # how do I modify this line to serve files?
        self.wfile.write(bytes(html, "utf8"))

http_server = ThreadingHTTPServer(("0.0.0.0", 4457), MyHttpRequestHandler)
http_server_thread = threading.Thread(target=http_server.serve_forever)
http_server_thread.daemon = True
http_server_thread.start()

async def start_tunnel():
    from pyexpose.providers.localhost_run import LocalRunConnector
    connector = LocalRunConnector()
    async with connector.connect() as session:
        async with session.tunnel(4457) as tunnel:
            print("Started tunnel, You can access your local server at: ", tunnel.ip)
            await asyncio.sleep(100000)

asyncio.run(start_tunnel())

Please look into official docs for more information - https://pyexpose.readthedocs.io/en/latest/

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

pyexpose-0.1.3.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

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

pyexpose-0.1.3-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file pyexpose-0.1.3.tar.gz.

File metadata

  • Download URL: pyexpose-0.1.3.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.12.2 CPython/3.10.12

File hashes

Hashes for pyexpose-0.1.3.tar.gz
Algorithm Hash digest
SHA256 99540f9d4449c247cb8e6aaf3e7180500c8884f21592ea584cd03746a54a3af6
MD5 60729d979a4dcd2171123987c0a1c826
BLAKE2b-256 be85adb6384384a468be5986a46378a2c68c67b7f9ffc2826ebef5cc697ef9a3

See more details on using hashes here.

File details

Details for the file pyexpose-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pyexpose-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.12.2 CPython/3.10.12

File hashes

Hashes for pyexpose-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b5d1fe30d282990ba7cd10c6a86ad9fb4613e84cf839eed7a9bc91c3e9e79359
MD5 d947211b3c58655362ce56515016509d
BLAKE2b-256 f4f7ff8d7502051da7d0421e9254a4721e41154f1befe4052901de51cdaf4e09

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