X-Git-Url: https://plomlompom.com/repos/feed.xml?a=blobdiff_plain;f=run.py;h=e1bbe5dafa4a43664f3b6839fe2659dc80ff0f8b;hb=54e6c8bccace28583cf9926aa00917a796628a00;hp=e0cdd8b8150dfbc0d8d54447a308ef79f6795037;hpb=78d82605facbfd468584f7cc6e6f5515af4be8be;p=plomtask diff --git a/run.py b/run.py index e0cdd8b..e1bbe5d 100755 --- a/run.py +++ b/run.py @@ -2,21 +2,20 @@ """Call this to start the application.""" from sys import exit as sys_exit from os import environ -from plomtask.misc import HandledException +from plomtask.exceptions import HandledException from plomtask.http import TaskHandler, TaskServer from plomtask.db import DatabaseFile -PATH_DB = environ.get('PATH_DB') +PLOMTASK_DB_PATH = environ.get('PLOMTASK_DB_PATH') HTTP_PORT = 8082 -TEMPLATES_DIR = 'templates' DB_CREATION_ASK = 'Database file not found. Create? Y/n\n' if __name__ == '__main__': try: - if not PATH_DB: - raise HandledException('PATH_DB not set.') - db_file = DatabaseFile(PATH_DB) + if not PLOMTASK_DB_PATH: + raise HandledException('PLOMTASK_DB_PATH not set.') + db_file = DatabaseFile(PLOMTASK_DB_PATH) if not db_file.exists: legal_yesses = {'y', 'yes', 'yes.', 'yes!'} reply = input(DB_CREATION_ASK) @@ -25,8 +24,7 @@ if __name__ == '__main__': else: print('Not recognizing reply as "yes".') raise HandledException('Cannot run without database.') - server = TaskServer(TEMPLATES_DIR, - ('localhost', HTTP_PORT), TaskHandler) + server = TaskServer(db_file, ('localhost', HTTP_PORT), TaskHandler) print(f'running at port {HTTP_PORT}') try: server.serve_forever()