You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
615 B

#!/usr/bin/python3
from http.server import HTTPServer, CGIHTTPRequestHandler
import urllib
import json as jsonlib
class POSTHandler(CGIHTTPRequestHandler):
def do_POST(self):
length = int(self.headers['Content-Length'])
data_string = self.rfile.read(length).decode('utf-8')
self.send_response(200)
self.end_headers()
data = jsonlib.loads(data_string)
print(data['text'])
return
if __name__ == '__main__':
server = HTTPServer(('0.0.0.0', 5001), POSTHandler)
print('Starting server...')
server.serve_forever()