Skip to content

Commit 7c20c4e

Browse files
committed
Startup the flask dev server the correct way
As indicated in the Flask documentation (https://flask.palletsprojects.com/en/2.3.x/server/#in-code) `app.run` is not the best way to run the flask dev server. It is better to run as `flask run`. This does not crash the server on errors, instead it logs and returns the error and stacktrace.
1 parent 2ea41ed commit 7c20c4e

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -eu
33
if [ ${MODE:-""} == "development" ]; then
44
if [ -f /app/requirements.txt ]; then pip install -r /app/requirements.txt; fi
5-
exec python web.py
5+
exec flask --app web.py run --debug --port 80 --host "0.0.0.0"
66
else
77
exec gunicorn -k egg:meinheld#gunicorn_worker -c "$GUNICORN_CONF" "$APP_MODULE"
88
fi

web.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,8 @@
2626

2727
# Import the app from the service consuming the template
2828
app_file = os.environ.get('APP_ENTRYPOINT')
29-
try:
30-
module_path = 'ext.app.{}'.format(app_file)
31-
import_module(module_path)
32-
except Exception:
33-
helpers.logger.exception('Exception raised when importing app code')
29+
module_path = 'ext.app.{}'.format(app_file)
30+
import_module(module_path)
3431

3532
#######################
3633
## Start Application ##

0 commit comments

Comments
 (0)