-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
55 lines (38 loc) · 1.17 KB
/
main.py
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
from escpos.printer import Serial
from flask import Flask
from flask import request
from flask_cors import CORS
from news import news
app = Flask(__name__)
CORS(app, supports_credentials=True)
printer = Serial(devfile='COM1',
baudrate=9600,
bytesize=8,
parity='N',
stopbits=1,
timeout=1.00,
dsrdtr=True)
last_link=""
@app.route('/printPV', methods=["POST"])
def printpv():
global last_link
request_body=request.json
if request_body["link"]==last_link:
return "Already Printed"
last_link=request_body["link"]
printer.image("Kassenzettel-Header.png")
printer.text(news)
printer.qr(request_body["link"],size=11)
printer.text("\n"+request_body["link"]+"\n")
printer.text("Dieser Link ist 7 Tage abrufbar.\n\n")
printer.text("Viel Erfolg bei deinen Klausuren!\n")
printer.text("Deine fachgruppe-informatik.de\n")
printer.cut()
return "ok"
app.run("0.0.0.0",port=6001)
"""
p.text("-----------------------------\n")
p.text("Web: fachgruppe-informatik.de\n")
p.text("Mail: [email protected]\n")
p.text("Tel: 0711 / 685 88367\n")
"""