Add global vars for the printer settings
This commit is contained in:
parent
8bb674e745
commit
0c20568a92
@ -19,6 +19,9 @@ limiter = Limiter(
|
|||||||
default_limits=["200 per day", "50 per hour"]
|
default_limits=["200 per day", "50 per hour"]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
SERIAL_PORT = '/dev/ttyAMA0'
|
||||||
|
BAUDRATE = 19200
|
||||||
|
|
||||||
# session['logged_in'] = False
|
# session['logged_in'] = False
|
||||||
|
|
||||||
def error_handler_limiter():
|
def error_handler_limiter():
|
||||||
@ -79,12 +82,12 @@ def logout():
|
|||||||
def print_image():
|
def print_image():
|
||||||
if session.get('logged_in'):
|
if session.get('logged_in'):
|
||||||
img = random.choice(os.listdir("static/images/")) #change dir name to whatever
|
img = random.choice(os.listdir("static/images/")) #change dir name to whatever
|
||||||
call(["lp", "-o fit-to-page", "static/images/" + img])
|
# call(["lp", "-o fit-to-page", "static/images/" + img])
|
||||||
# printer = Adafruit_Thermal('/dev/serial0', 19200, timeout=5)
|
printer = Adafruit_Thermal(SERIAL_PORT, BAUDRATE, timeout=5)
|
||||||
# printer.begin()
|
printer.begin()
|
||||||
# printer.feed(1)
|
printer.feed(1)
|
||||||
# # printer.printImage(dickbutt, True)
|
printer.printImage("static/images/" + img, True)
|
||||||
# # printer.feed(2)
|
printer.feed(2)
|
||||||
return redirect(url_for('display_index_page'))
|
return redirect(url_for('display_index_page'))
|
||||||
else:
|
else:
|
||||||
return redirect(url_for('login'))
|
return redirect(url_for('login'))
|
||||||
@ -94,7 +97,7 @@ def print_image():
|
|||||||
def print_text():
|
def print_text():
|
||||||
if session.get('logged_in'):
|
if session.get('logged_in'):
|
||||||
if len(request.form['message']) < 200:
|
if len(request.form['message']) < 200:
|
||||||
printer = Adafruit_Thermal('/dev/ttyAMA0', 19200, timeout=5)
|
printer = Adafruit_Thermal(SERIAL_PORT, BAUDRATE, timeout=5)
|
||||||
printer.begin()
|
printer.begin()
|
||||||
printer.justify('L')
|
printer.justify('L')
|
||||||
printer.println((request.form['message']).encode())
|
printer.println((request.form['message']).encode())
|
||||||
|
Loading…
Reference in New Issue
Block a user