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):
server = await start_server(
ServerConfig.load(prefix="here"),
namespace={"app": app}
)
app = web.Application()
app.on_startup.append(start_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="test3")
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)])
app instance is available: <Application 0x7fcc67464e80>
!curl http://127.0.0.1:8080/debug
...