Use waitress rather than Flask's built in web server
It's not production grade
This commit is contained in:
parent
9182f1108f
commit
bee8859b94
3
app/__main__.py
Normal file
3
app/__main__.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from .routes import run_app
|
||||
|
||||
run_app()
|
|
@ -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))
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user