Pick up api information with local socket

Asked

Viewed 22 times

0

Good afternoon, I am developing a program to process Whatsapp messages and answer them (chatbot) and for that I bought a program called zapmax, in it is detected the message and is sent to the server via api with the method POST, so I created a local server with socket, but I cannot receive the information with this code I receive the following on the terminal:

def aceitar_conexao():
    while True:
        client = {}
        endereco, client = servidor.accept()
        msg = endereco.recv(1024)
        print(msg)

message that appears on the terminal: b'POST / HTTP/1.1 r nContent-Type: application/json r nHost: 10.1.1.124:7000 r nContent-Length: 177 r nExpect: 100-continue r nConnection: Keep-Alive r n r r n'

so I tried to file a request like this:

def aceitar_conexao():
    while True:
        client = {}
        endereco, client = servidor.accept()
        ht = 'https://10.1.1.124:' + str(client[1])
        mnsg = '\"{}\"'.format(ht)
        request = requests.get(ht)
        print(request)

And this way nothing happens but close the terminal, if someone can give me a light, I’ll be eternally grateful, I’m still a junior developer so I don’t have much experience with it, I will leave tbm an image that the support sent me containing the information sent by the program: Informações passada pelo method POST

  • 1

    I think it is by request get and post and not via socket

1 answer

-1

Do not use sockets, use any module that implements a real HTTP server, such as Simplehttpserver (Python 2.x) or http.server (Python 3.x).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.