def do_POST(self): print("POSTING") log.info(self.headers) body = self.get_post_body() log.info(body) path = self.get_clean_path(self.path) router = Router("post", path, query=body) response = router.execute() self.send_response(200) self.send_header("Content-type", "text/html") self.end_headers() self.wfile.write(self.btext(response))
def do_GET(self): print("GETTING") log.info(self.path) path, resp = self.get_path_query() router = Router("get", path, query=resp) response = router.execute() self.send_response(200) if ".css" in resp: self.send_header("Content-type", "text/css") elif ".js" in resp: self.send_header("Content-type", "text/javascript") else: self.send_header("Content-type", "text/html") self.end_headers() self.wfile.write(self.btext(response))