ghenny/ghenny

24 lines
615 B
Python
Executable File

#!/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()