How to make python server public to other computers in a Linux machine?

I have an ubuntu computer and I want it to act as a server. How do I need to configure the ubuntu computer to be accessible from other computers? Let’s say I have this very simple python TCP server:

from socket import socket

with socket() as server:
    server.bind(("", 5555))
    server.listen(5)
    print("[+] Server Listening")
    client, addr = server.accept()
    print(f"client connected from address {addr}")

How can I make this server public to other computers to connect?

Answer

One way you can expose your local service publicly is by using some kind of application like localtunnel or ngrok

Example with ngrok: ngrok http 5555

Example with localtunnel: lt –port 5555

These applications will open a tunnel on a random port locally and forward all the connections it gets on the application generated URL to the port you have specified.

Do not use these for production. Not very reliable approach