diff --git a/setup.cfg b/setup.cfg index c7b9f4d..7403e5f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -40,4 +40,5 @@ console_scripts = wuttapos.commands = open = wuttapos.commands:Open + serve = wuttapos.commands:Serve status = wuttapos.commands:Status diff --git a/wuttapos/commands.py b/wuttapos/commands.py index 67a08c8..8a1c88f 100644 --- a/wuttapos/commands.py +++ b/wuttapos/commands.py @@ -24,6 +24,7 @@ WuttaPOS commands """ +import logging import sys from rattail import commands @@ -31,6 +32,9 @@ from rattail import commands from wuttapos import __version__ +log = logging.getLogger(__name__) + + def main(*args): """ Main entry point for WuttaPOS command system @@ -63,6 +67,26 @@ class Open(commands.Subcommand): run_app(self.config) +class Serve(commands.Subcommand): + """ + Run the POS app as a web service + """ + name = 'serve' + description = __doc__.strip() + + def run(self, args): + import flet as ft + from wuttapos.app import main + + host = self.config.get('wuttapos', 'serve.host', + default='0.0.0.0') + port = self.config.getint('wuttapos', 'serve.port', + default=8332) + + log.info(f"will serve WuttaPOS on http://{host}:{port}") + ft.app(target=main, view=None, host=host, port=port) + + class Status(commands.Subcommand): """ Show status of the POS lane