Experimental communication tools (televex screen + televex print) https://televex.vvvvvvaria.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

52 lines
1.1 KiB

# https://github.com/python-escpos/python-escpos
# https://python-escpos.readthedocs.io/en/latest/
import sys
import os
import flask
from flask import request
import urllib
import json
from escpos.escpos import Escpos
from escpos import printer
# Create the application.
APP = flask.Flask(__name__)
# File Initialization
try:
lp = printer.File("/dev/usb/lp0")
except:
lp = sys.stdout
# USB initialization
# Bus 001 Device 006: ID 04b8:0e15 Seiko Epson Corp.
# lp = printer.Usb(0x4b8, 0xe15)
lp.text('test :)')
lp.image('')
lp.cut()
@APP.route('/', methods=['GET', 'POST'])
def index():
plaintext = request.args.get('plaintext', '')
if plaintext:
lp.text(plaintext)
lp.cut()
url = 'https://multi.vvvvvvaria.org/API/latest/5'
response = urllib.request.urlopen(url).read()
multifeeder = json.loads(response)
url = 'https://multi.vvvvvvaria.org/API/today/'
response = urllib.request.urlopen(url).read()
feedstoday = json.loads(response)
return flask.render_template('index.html', plaintext=plaintext, multifeeder=multifeeder, feedstoday=feedstoday)
if __name__ == '__main__':
APP.debug=True
APP.run(port=5000)