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:
committed by
GitHub
parent
2b826aa834
commit
66348ccc0a
22
examples/docker-flask/app.py
Normal file
22
examples/docker-flask/app.py
Normal 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)
|
||||
Reference in New Issue
Block a user