home · contact · privacy
Re-structure whole code into more package-typical file modularity.
[plomtask] / run.py
diff --git a/run.py b/run.py
new file mode 100755 (executable)
index 0000000..644fc4a
--- /dev/null
+++ b/run.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python3
+"""Call this to start the application."""
+from sys import exit as sys_exit
+from plomtask.misc import HandledException
+from plomtask.http import TaskHandler, TaskServer
+
+HTTP_PORT = 8082
+
+
+if __name__ == '__main__':
+    try:
+        server = TaskServer(('localhost', HTTP_PORT), TaskHandler)
+        print(f'running at port {HTTP_PORT}')
+        try:
+            server.serve_forever()
+        except KeyboardInterrupt:
+            print('aborting due to keyboard interrupt')
+        server.server_close()
+    except HandledException as e:
+        print(f'Aborting due to: {e}')
+        sys_exit(1)