1
0
mirror of https://github.com/python-escpos/python-escpos synced 2025-10-23 09:30:00 +00:00

Added example with Docker and Flask (#519)

* Added example with Docker and Flask

* set flask debug flag to False

* new line at the end of file

* format with black

---------

Co-authored-by: Ricardo Sanchez Alba <r2sanchezalba@gmail.com>
This commit is contained in:
Ricardo Sánchez Alba
2023-05-18 07:06:06 -06:00
committed by GitHub
parent 2b826aa834
commit 66348ccc0a
4 changed files with 77 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
import escpos
from escpos.printer import *
from flask import Flask, jsonify, request, redirect, session, url_for
import sys
from io import BytesIO
# Initialize Flask app
app = Flask(__name__)
@app.route("/", methods=["GET"])
def do_print():
# p = Usb(0x04b8, 0x0e28, 0)
p = CupsPrinter(host="localhost", port=631, printer_name="TM-T20III")
p.text("Hello World\n")
p.cut()
p.close()
return "OK"
if __name__ == "__main__":
app.run(debug=False, host="0.0.0.0", port=9999)