pythoncurlserversocketserver

How to fix cur error: could not resolve host error


I'm learning networks (socket lib in python) and have a problem. When I make a request to this app answer on this request is an error: "Could not resolve host: POST"

Here is my code

    import socket

    sock = socket.socket()
    sock.bind(('',9091))
    
    print("DATABASE INITED")
    while True:
        sock.listen(1)
        connection, address = sock.accept()
        buf = connection.recv(64)
        if len(buf) > 0:
            print(buf)
            conn.send(buf.upper())
    
    conn.close()

And here is code to curl request

curl -d "data = 'example'" POST 127.0.0.1:9091

Query and program located on the one Linux computer.


Solution

  • Try this:

    curl --data "data = 'example'" 127.0.0.1:9091