televex 3 years ago
parent
commit
8fde14f8d8
  1. 2
      .gitignore
  2. 4
      .gitmodules
  3. 11
      Makefile
  4. 7
      README.md
  5. 52
      print/start.py
  6. 16
      print/static/stylesheet.css
  7. 43
      print/templates/index.html
  8. 2
      requirements.txt
  9. 0
      screen/televex.py
  10. 0
      screen/texts/about.txt
  11. 1
      tools/ascii-art-but-with-unicode

2
.gitignore

@ -1 +1,3 @@
.venv*
venv*
print/__pycache__*

4
.gitmodules

@ -1,3 +1,3 @@
[submodule "tools/ascii-art-but-with-unicode"]
path = tools/ascii-art-but-with-unicode
[submodule "screen/tools/ascii-art-but-with-unicode"]
path = screen/tools/ascii-art-but-with-unicode
url = https://git.vvvvvvaria.org/mb/ascii-art-but-with-unicode.git

11
Makefile

@ -0,0 +1,11 @@
setup:
@python3 -m venv .venv && \
.venv/bin/pip install -r requirements.txt
screen:
@cd screen && \
.venv/bin/python televex.py
print:
$cd print && \
.venv/bin/python start.py

7
README.md

@ -0,0 +1,7 @@
# TeleVex
https://televex.vvvvvvaria.org/
Experimental communication tools (televex screen + televex print).

52
print/start.py

@ -0,0 +1,52 @@
# 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)

16
print/static/stylesheet.css

@ -0,0 +1,16 @@
body{
color:magenta;
margin:2em;
}
div#print,
div#multifeeder,
div#webcam{
}
div#multifeeder div.multipost{
margin:1em 0;
}
div#webcam img{
width:500px;
}

43
print/templates/index.html

@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset="utf-8" />
<title>TeleVex (print)</title>
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='stylesheet.css')}}">
</head>
<body>
<div id="main">
<div id="print">
<h1>Plain Text Printing Point (ASCII only)</h1>
<form action="" method="GET">
<textarea name="plaintext" cols="42" rows="30">{{ plaintext }}</textarea>
<br>
<br>
<input class="submit" type="submit" value="print"/>
</form>
<br>
<h1>Image printing access point</h1>
<form action="" method="GET">
<button>Select image</button>
<input class="submit" type="submit" value="print image"/>
</form>
</div>
<br>
<div id="multifeeder">
<h1 id="title">Multifeeder</h1>
<div>Last 5 posts added to the Televex print stream:</div>
<br>
{% for post in multifeeder %}
<div class="multipost">
<strong>Title</strong>: {{ post.title }}<br>
<strong>Link</strong>: {{ post.link }}<br>
<strong>Author</strong>: {{ post.author }}<br>
<strong>Date</strong>: {{ post.published }}<br>
</div>
{% endfor %}
</div>
</div>
</body>
</html>

2
requirements.txt

@ -2,4 +2,4 @@ feedparser
icalendar
requests
pypandoc
pyhyphen
python-escpos

0
televex.py → screen/televex.py

0
texts/about.txt → screen/texts/about.txt

1
tools/ascii-art-but-with-unicode

@ -1 +0,0 @@
Subproject commit 24c3d8af3e94cf3ce439a945605600d16475f0c4
Loading…
Cancel
Save