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

26 lines
886 B
Python

from http.server import HTTPServer, BaseHTTPRequestHandler
import json
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
def do_POST(self):
content_length = int(self.headers['Content-Length'])
body = self.rfile.read(content_length)
self.send_response(204)
self.send_header('Access-Control-Allow-Origin', '*')
self.end_headers()
#print(body)
for item in body.decode().split(','):
print(item)
def do_OPTIONS(self):
print(self.headers)
self.send_response(204)
self.send_header('Access-Control-Allow-Origin', '*')
self.send_header('Access-Control-Allow-Method', 'POST, GET, OPTIONS')
self.send_header('Access-Control-Allow-Headers', 'content-type')
self.end_headers()
httpd = HTTPServer(('localhost', 8000), SimpleHTTPRequestHandler)
httpd.serve_forever()