From 18774e2e797f64cf951b3ba1ea8051ea6ad525f4 Mon Sep 17 00:00:00 2001 From: Louie Shprung Date: Sat, 1 Apr 2023 17:14:09 -0700 Subject: First commit --- backend/server.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 backend/server.py (limited to 'backend/server.py') diff --git a/backend/server.py b/backend/server.py new file mode 100644 index 0000000..b8e1091 --- /dev/null +++ b/backend/server.py @@ -0,0 +1,26 @@ +import http.server + +from config import * + +class MyServer(http.server.BaseHTTPRequestHandler): + def do_GET(self): + self.send_response(200) + self.send_header("Content-type", "application/json") + self.send_header("Access-Control-Allow-Origin", "*") + self.send_header("Access-Control-Allow-Headers", "content-type") + self.end_headers() + output = exec(open("." + self.path).read()) + self.wfile.write(output.encode()) + + +if __name__ == "__main__": + webServer = http.server.HTTPServer((Config.hostName, Config.serverPort), MyServer) + print("Server started http://%s:%s" % (Config.hostName, Config.serverPort)) + + try: + webServer.serve_forever() + except KeyboardInterrupt: + pass + + webServer.server_close() + print("Server stopped.") -- cgit