Running with AIOHTTP#
Run the server#
Run the SSH server on aiohttp startup
from aiohttp import web
from herethere.here import ServerConfig, start_server
async def start_server_here(app):
app["here_server"] = await start_server(
ServerConfig.load(prefix="here"),
namespace={"app": app}
)
async def stop_server_here(app):
await app["here_server"].stop()
app = web.Application()
app.on_startup.append(start_server_here)
app.on_cleanup.append(stop_server_here)
if __name__ == "__main__":
web.run_app(app)
Connect to the SSH server from the Jupyter#
%load_ext herethere.magic
%connect-there
%%there
from aiohttp import web
async def handle(request):
return web.Response(text="...")
print(f"app instance is available: {app}")
app.router._frozen = False
app.add_routes([web.get('/debug', handle)])
!curl http://127.0.0.1:8080/debug