This repository was archived by the owner on Feb 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdotdot.py
More file actions
56 lines (45 loc) · 1.38 KB
/
dotdot.py
File metadata and controls
56 lines (45 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from flask import Flask
import flask
from dotenv import load_dotenv
from text_to_font.transformations import word_to_ascii
import toprint as tp
load_dotenv()
dotdot = Flask(__name__)
class CharacterLimitExceeded(Exception):
"""Printer exceeded line width of 80 characters"""
pass
@dotdot.route("/")
def test():
return "<p>Hello, World!</p>"
@dotdot.route("/print", methods=['POST'])
def print(response):
content = flask.request.json.get('content')
sanitized = tp.sanitize(content)
sanlist = tp.eightyCharChunk(sanitized)
for sanstring in sanlist:
tp.toprint(sanstring)
return response.status
@dotdot.route("/print/test", methods=['POST'])
def print_test(response):
tp.toprint('hello world!')
return response.status
@dotdot.route("/print/raw", methods=['POST'])
def print_raw(response):
content = flask.request.json.get('content')
tp.toprint(content)
return response.status
@dotdot.route("/print/ascii", methods=['POST'])
def print_ascii(response):
content = flask.request.json.get('content')
sanitized = tp.sanitize(content).split('\n')
for sanstring in sanitized:
if len(sanstring) > 65:
raise CharacterLimitExceeded
tp.toprint(sanstring)
return response.status
@dotdot.route("/print/image")
def print_image(response):
return "stuff"
@dotdot.route("/bell")
def bell(response):
return "ding"