summaryrefslogtreecommitdiff
path: root/backend/server.py
diff options
context:
space:
mode:
authorLouie Shprung <lshprung@scu.edu>2023-04-01 17:14:09 -0700
committerLouie Shprung <lshprung@scu.edu>2023-04-01 17:14:09 -0700
commit18774e2e797f64cf951b3ba1ea8051ea6ad525f4 (patch)
treed600833a04fb7209ac48f3078fbfab4afa0bf7cc /backend/server.py
First commit
Diffstat (limited to 'backend/server.py')
-rw-r--r--backend/server.py26
1 files changed, 26 insertions, 0 deletions
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.")