I looked around but I although I saw a lot of similar questions, none is the same and none have solved my issue. I have a python server built with aiohttp. I works just fine when running on localhost.
Now I am considering accessing it from a distant machine. I however do not have access to that machine at the current time so I decided to develop my server using virtualbox to simulate having two machines.
I don't understand how I am supposed to access it from the real computer though. The issue is double:
- how does one render an aiohttp server available from a distance, in general?
- does the fact that I am running it on virtualbox change anything?
Here is the code I believe to be relevant:
import socketio
from aiohttp import web
...
_server = socketio.AsyncServer(async_mode = "aiohttp")
_app = web.Application()
_server.attach(_app)
...
async def index(request):
if request.method == "POST":
data = await request.json()
return web.json_response(await process_request(data))
return web.json_response({"Unsupported method": request.method})
...
_app.router.add_post("/", name="index", handler=index)
...
web.run_app(_app, port=port, host="0.0.0.0")
My virtual machine runs on a Debian 10 image. I have tried forwarding its ports to those of my real machine, with no success. Its network adapter 1 is set to NAT.
Also I'm a total noob with this so if you see something in my code that seems like a bad habit do not hesitate to tell me in the comments :D
Thanks