Skip to 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.

Notifications You must be signed in to change notification settings

hari01584/pyexpose

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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/

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages