epson-tm-t20iii #1

Merged
n07070 merged 34 commits from epson-tm-t20iii into master 2022-05-04 11:57:09 +02:00
Showing only changes of commit e6a046d4e6 - Show all commits

View File

@ -8,22 +8,35 @@
# Following are the librairies we import,
from flask import Flask # Used for the web framework
from printer import Printer
from printer import Printer # The wrapper for the printer class
import toml # Used for the config file parsing
import pprint
# Load the configuration file
try:
configuration_file = toml.load("configuration/config.toml")
except TypeError :
print("Unable to load the config file: invalid type or is a list containing invalid types")
exit(-1)
except toml.TomlDecodeError:
print("An error occured while decoding the file")
exit(-1)
except Exception as e:
print("Error while loading file : " + str(e))
pprint.pprint(configuration_file)
# We define the app module used by Flask
app = Flask(__name__)
app.secret_key = b'\x98>3nM[D\xa4\xd4\xd0K\xab?oM.`\x98'
# TODO: Get this secret key from a config file
app.secret_key = configuration_file["secrets"]["flask_secret_key"]
# Printer connection
# Uses the class defined in the printer.py file
# Define the USB connections here.
# TODO: move this to a config file
vendor_id = 0x04b8
device_id = 0x0e28
vendor_id = configuration_file["printer"]["vendor_id"]
device_id = configuration_file["printer"]["device_id"]
printer = Printer(app)