From 24092aa9bc3dafe32eaae4ef791c954ea594f800 Mon Sep 17 00:00:00 2001 From: Philipp Klaus Date: Sun, 20 Nov 2016 15:10:07 +0100 Subject: [PATCH] Adding README and improving the CLI --- README.md | 27 +++++++++++++++++++++++++++ brother_ql_web.py | 13 +++++++------ 2 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..e709301 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +### brother\_ql\_web + +This is a web service to print labels on Brother QL label printers. + +It offers: +* an API at */api/print/text/Your_Text?font_size=100&font_family=Minion%20Pro&font_style=Semibold* + to print a label containing 'Your Text' with the specified font properties. + +Here's its command line interface: + + usage: brother_ql_web.py [-h] [--port PORT] [--loglevel LOGLEVEL] + [--font-folder FONT_FOLDER] + [--model {QL-500,QL-550,QL-560,QL-570,QL-580N,QL-650TD,QL-700,QL-710W,QL-720NW,QL-1050,QL-1060N}] + printer + + positional arguments: + printer String descriptor for the printer to use (like + tcp://192.168.0.23:9100 or file:///dev/usb/lp0) + + optional arguments: + -h, --help show this help message and exit + --port PORT + --loglevel LOGLEVEL + --font-folder FONT_FOLDER + folder for additional .ttf/.otf fonts + --model {QL-500,QL-550,QL-560,QL-570,QL-580N,QL-650TD,QL-700,QL-710W,QL-720NW,QL-1050,QL-1060N} + The model of your printer (default: QL-500) diff --git a/brother_ql_web.py b/brother_ql_web.py index 2f7604c..33888d2 100755 --- a/brother_ql_web.py +++ b/brother_ql_web.py @@ -1,10 +1,7 @@ #!/usr/bin/env python """ -This is a web server to print labels. - -Go to [/api/print/text/Your_Text](/api/print/text/) -to print a label (replace Your_Text with your text). +This is a web service to print labels on Brother QL label printers. """ import sys, logging, socket, os, subprocess, functools @@ -39,7 +36,11 @@ DEFAULT_FONTS = [ @route('/') def index(): - return markdown.markdown(__doc__) + INDEX_MD = __doc__ + """ + Go to [/api/print/text/Your_Text](/api/print/text/) + to print a label (replace `Your_Text` with your text). + """ + return markdown.markdown(INDEX_MD) def get_fonts(folder=None): """ @@ -172,7 +173,7 @@ def print_text(content=None): def main(): global DEBUG, FONTS, DEFAULT_FONT, MODEL, BACKEND_CLASS, BACKEND_STRING_DESCR import argparse - parser = argparse.ArgumentParser() + parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--port', default=8013) parser.add_argument('--loglevel', type=lambda x: getattr(logging, x.upper()), default='WARNING') parser.add_argument('--font-folder', help='folder for additional .ttf/.otf fonts')