Use waitress rather than Flask's built in web server

It's not production grade
This commit is contained in:
Jake Howard 2020-05-12 22:11:54 +01:00
parent 9182f1108f
commit bee8859b94
No known key found for this signature in database
GPG Key ID: 57AFB45680EDD477
3 changed files with 10 additions and 6 deletions

3
app/__main__.py Normal file
View File

@ -0,0 +1,3 @@
from .routes import run_app
run_app()

View File

@ -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='<ip address>',
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))

View File

@ -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