Skip to content

Integrating the bot with a python server #42

Answered by mordi9
mordi9 asked this question in Q&A
Discussion options

You must be logged in to vote

I use a server API and want to get an answer to a question sent to the server is basically what I have now

from http.server import BaseHTTPRequestHandler, HTTPServer
from urllib.parse import urlparse

chatMsg = Chat(language="he")
class S(BaseHTTPRequestHandler):
    def Get(self):
        queryStr = urlparse(self.path).query
        query = {}
        if "&" in queryStr:
            for qc in queryStr.split("&"):
                z = qc.split("=")
                query[z[0]]=z[1]
        elif "=" in queryStr:
            z = queryStr.split("=")
            query[z[0]]=z[1]
        return query
    
    def do_GET(self):
        GET = self.Get()
        message = GET.get("message")
       …

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@ahmadfaizalbh
Comment options

@mordi9
Comment options

Answer selected by mordi9
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants