Update little printer requirements
This commit is contained in:
23
src/web.py
23
src/web.py
@@ -1,4 +1,4 @@
|
||||
from flask import Flask, request
|
||||
from flask import Flask, request, flash
|
||||
from werkzeug.utils import secure_filename
|
||||
from printer import Printer
|
||||
import time
|
||||
@@ -15,28 +15,27 @@ class Web(object):
|
||||
def print_sms(self, texte, sign: str):
|
||||
# TODO: verify the texte before printing it here ?
|
||||
self.app.logger.debug("Printing : " + str(texte) + " from " + str(sign))
|
||||
if not os.getenv('LIPY_DEBUG'):
|
||||
time.sleep(1)
|
||||
try:
|
||||
self.printer.print_sms(texte, sign)
|
||||
except Exception as e:
|
||||
self.app.logger.error(e)
|
||||
flash("Error while printing the SMS : "+ str(e))
|
||||
|
||||
return self.printer.print_sms(texte, sign)
|
||||
flash("You message has been printed :)")
|
||||
|
||||
def print_image(self, image, sign: str) -> bool:
|
||||
|
||||
def print_image(self, image, sign: str):
|
||||
self.app.logger.debug("Uploading file")
|
||||
try:
|
||||
self.app.logger.debug("Uploading file from " + str(sign))
|
||||
if self.upload_file(image):
|
||||
self.app.logger.debug("File has been uploaded, printing...")
|
||||
self.printer.print_img(os.path.join(self.app.config['UPLOAD_FOLDER'], secure_filename(image.filename)), sign)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
except Exception as e:
|
||||
self.app.logger.error(e)
|
||||
raise Exception
|
||||
flash("Could not upload file." + str(e))
|
||||
|
||||
else:
|
||||
flash("Could not upload file.",'error')
|
||||
return False
|
||||
flash("Your image has been printed :)")
|
||||
|
||||
def login(username: str,password: str) -> bool:
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user