Add SSL context and folder creation for the uploads
This commit is contained in:
parent
38b3acfb89
commit
1735e468aa
13
src/main.py
13
src/main.py
@ -40,6 +40,16 @@ vendor_id = configuration_file["printer"]["vendor_id"]
|
|||||||
device_id = configuration_file["printer"]["device_id"]
|
device_id = configuration_file["printer"]["device_id"]
|
||||||
UPLOAD_FOLDER = str(configuration_file["printer"]["upload_folder"])
|
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'}
|
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'}
|
||||||
|
|
||||||
# Output the config file
|
# Output the config file
|
||||||
@ -61,6 +71,9 @@ printer.init_printer()
|
|||||||
# Web routes
|
# Web routes
|
||||||
web = Web(app, printer)
|
web = Web(app, printer)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app.run(ssl_context='adhoc')
|
||||||
|
|
||||||
|
|
||||||
limiter = Limiter(
|
limiter = Limiter(
|
||||||
app,
|
app,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user