diff --git a/src/web.py b/src/web.py index b31cd10..8bcb92c 100644 --- a/src/web.py +++ b/src/web.py @@ -1,10 +1,13 @@ +""" +Manage all of the inputs from a web source +""" + import os -from flask import flash from werkzeug.utils import secure_filename from task import TextTask, ImageTask, CutTask -class Web(object): +class Web: """Web is the class that gets all of the information from web calls ( API and Web page ) and provides checks before sending stuff to printing""" @@ -65,16 +68,19 @@ class Web(object): return True - def login(self, username: str, password: str) -> bool: - """Not implemented""" - return + # def login(self, username: str, password: str) -> bool: + # """Not implemented""" + # return - def logout(self, username: str, password: str) -> bool: - """Not implemented""" - return + # def logout(self, username: str, password: str) -> bool: + # """Not implemented""" + # return def allowed_file(self, filename) -> bool: - self.app.logger.debug("Is the filename allowed ?") + """ + Check if the file extension is allowed + """ + self.app.logger.debug("Checking if the file extension is allowed") return ( "." in filename and filename.rsplit(".", 1)[1].lower() @@ -82,8 +88,11 @@ class Web(object): ) def upload_file(self, image) -> bool: + """ + Save the file after executing checks on it + """ self.app.logger.debug("Validating file") - if image: + if not image is None or not image == "": if self.allowed_file(image.filename): filename = secure_filename(image.filename) self.app.logger.debug("File valid") @@ -99,16 +108,10 @@ class Web(object): ) return True - self.app.logger.error( - "Could not save file because the filename is forbidden" - ) - return False - - else: - self.app.logger.error( - "Could not save file, it seems to be null ? : " + str(filename) - ) - return False + self.app.logger.error( + "Could not save file because the filename is forbidden" + ) + return False def get_queue_state(self): """Return current queue state"""