From 1735e468aa601a5d27f1c3e2b75eafa9e244ce62 Mon Sep 17 00:00:00 2001 From: nono Date: Tue, 10 Jun 2025 19:37:59 +0200 Subject: [PATCH] Add SSL context and folder creation for the uploads --- src/main.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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,