Week #45 - 2022

Week #45 - 2022

·

1 min read

Python has makefile function that you can use to send and receive messages from clients and servers. Using makefile (instead of send() and recv()) will return a file-like object. Which means you can use file methods like read and readline. In some cases this is more convenient.

import socket


def serve(host, port):
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    sock.bind((host, port))
    sock.listen(1)

    conn, addr = sock.accept()
    print(f"Connected by {addr}")

    with conn:        
        f = conn.makefile(mode="rw")

        while True:
            m = f.readline()
            print(f"msg: {m!r}")
            if not m:
                break

            f.write(m)
            f.flush()
    sock.close()


if __name__ == '__main__':
    serve("127.0.0.1", 8081)

Been reading the Weak Hero webtoon. I stumbled upon this webtoon thanks to Youtube. I never actually read any webtoon before. I usually read mangas. But this one piques my interest and it is quite a fun read.

Weak Hero Cover

I have been fooling around with Mapbox API. There is this slick interface I see years ago. And it looks great. So I wonder if I can remake it using MapBox.

The original interface can be found at Fantasy.

Flight selection UI

I got close enough.

Mapbox version