Skip to content

Instantly share code, notes, and snippets.

@lmzach09
Created September 1, 2019 05:18
Show Gist options
  • Select an option

  • Save lmzach09/8bbcfdcb3f69ede31dca88431e5b6ffb to your computer and use it in GitHub Desktop.

Select an option

Save lmzach09/8bbcfdcb3f69ede31dca88431e5b6ffb to your computer and use it in GitHub Desktop.
snippet from web server in python 3
class Handler(http.server.SimpleHTTPRequestHandler):
def __init__(self, *args, **kwargs):
super().__init__(*args, directory=DIRECTORY, **kwargs)
def do_POST(self):
self.send_response(200)
content_length = int(self.headers['Content-Length'])
post_body = self.rfile.read(content_length)
self.end_headers()
print('user query', post_body)
google_search_chatbot_reply = chatbot_query(post_body)
self.wfile.write(str.encode(google_search_chatbot_reply))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment