[Python] validate http response in python

Discussão em 'Python' iniciado por Stack, Agosto 29, 2025.

  1. Stack

    Stack Membro Participativo

    I am making a simple webserver and I have a python function for handling request like so:

    def handle_request(client_connection):
    request = client_connection.recv(1024)
    print(request.decode())
    http_response = """\
    HTTP/1.1 200 OK\n
    Hello, World!
    """
    client_connection.sendall(http_response)


    Now whenever I type something else on my browser(client) I still get a 200 OK response. How can I handle the 404 response?

    Continue reading...

Compartilhe esta Página