diff --git a/app/__main__.py b/app/__main__.py new file mode 100644 index 0000000..03a424c --- /dev/null +++ b/app/__main__.py @@ -0,0 +1,3 @@ +from .routes import run_app + +run_app() diff --git a/app/routes.py b/app/routes.py index 6977be3..7886de9 100644 --- a/app/routes.py +++ b/app/routes.py @@ -9,6 +9,7 @@ import io import json import os import urllib.parse as urlparse +import waitress app.config['APP_ROOT'] = os.getenv('APP_ROOT', os.path.dirname(os.path.abspath(__file__))) app.config['STATIC_FOLDER'] = os.getenv('STATIC_FOLDER', os.path.join(app.config['APP_ROOT'], 'static')) @@ -151,7 +152,9 @@ def run_app(): parser.add_argument('--host', default='127.0.0.1', metavar='', help='Specifies the host address to use (default 127.0.0.1)') parser.add_argument('--debug', default=False, action='store_true', - help='Activates debug mode for the Flask server (default False)') + help='Activates debug mode for the server (default False)') args = parser.parse_args() - - app.run(host=args.host, port=args.port, debug=args.debug) + if args.debug: + app.run(host=args.host, port=args.port, debug=args.debug) + else: + waitress.serve(app, listen="{}:{}".format(args.host, args.port)) diff --git a/whoogle-search b/whoogle-search index e8bcc7f..3393528 100755 --- a/whoogle-search +++ b/whoogle-search @@ -17,11 +17,9 @@ export STATIC_FOLDER=$APP_ROOT/static mkdir -p $STATIC_FOLDER -pkill flask - # Check for regular vs test run if [[ $SUBDIR == "test" ]]; then pytest -sv else - flask run --host="0.0.0.0" --port=$PORT + python3 -m app --port $PORT fi