diff --git a/src/main.py b/src/main.py index e26081f..6b3cf57 100644 --- a/src/main.py +++ b/src/main.py @@ -40,6 +40,16 @@ vendor_id = configuration_file["printer"]["vendor_id"] device_id = configuration_file["printer"]["device_id"] UPLOAD_FOLDER = str(configuration_file["printer"]["upload_folder"]) +try: + os.mkdir(UPLOAD_FOLDER) + app.logger.debug(f"Directory '{UPLOAD_FOLDER}' created successfully.") +except FileExistsError: + app.logger.error(f"Directory '{UPLOAD_FOLDER}' already exists.") +except PermissionError: + app.logger.error(f"Permission denied: Unable to create '{UPLOAD_FOLDER}'.") +except Exception as e: + app.logger.error(f"An error occurred: {e}") + ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'} # Output the config file @@ -61,6 +71,9 @@ printer.init_printer() # Web routes web = Web(app, printer) +if __name__ == "__main__": + app.run(ssl_context='adhoc') + limiter = Limiter( app,