remove wsgi.py - always serve with whitenoise

We're now running our app as a wsgi app locally, so don't need to
distinguish between the two processes by having wsgi and application.py
whitenoise just serves static files nicely - we don't lose anything
by doing that locally.
This commit is contained in:
Leo Hemsted
2017-11-07 11:50:13 +00:00
parent 0535702707
commit 2cd77e628e
5 changed files with 11 additions and 33 deletions

View File

@@ -4,7 +4,6 @@ from flask import (
jsonify, jsonify,
request, request,
url_for, url_for,
current_app
) )
from flask_login import login_required from flask_login import login_required
@@ -21,27 +20,11 @@ from app.utils import (
get_template, get_template,
get_time_left, get_time_left,
get_letter_timings, get_letter_timings,
REQUESTED_STATUSES,
FAILURE_STATUSES, FAILURE_STATUSES,
SENDING_STATUSES,
DELIVERED_STATUSES, DELIVERED_STATUSES,
) )
def get_status_arg(filter_args):
if 'status' not in filter_args or not filter_args['status']:
return REQUESTED_STATUSES
elif filter_args['status'] == 'sending':
return SENDING_STATUSES
elif filter_args['status'] == 'delivered':
return DELIVERED_STATUSES
elif filter_args['status'] == 'failed':
return FAILURE_STATUSES
else:
current_app.logger.info('Unrecognised status filter: {}'.format(filter_args['status']))
return REQUESTED_STATUSES
@main.route("/services/<service_id>/notification/<uuid:notification_id>") @main.route("/services/<service_id>/notification/<uuid:notification_id>")
@login_required @login_required
@user_has_permissions('view_activity', admin_override=True) @user_has_permissions('view_activity', admin_override=True)

View File

@@ -1,6 +1,15 @@
import os
from flask import Flask from flask import Flask
from whitenoise import WhiteNoise
from app import create_app from app import create_app
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'app', 'static')
STATIC_URL = 'static/'
app = Flask('app') app = Flask('app')
create_app(app) create_app(app)
application = WhiteNoise(app, STATIC_ROOT, STATIC_URL)

View File

@@ -1,7 +1,7 @@
--- ---
buildpack: python_buildpack buildpack: python_buildpack
command: scripts/run_app_paas.sh gunicorn -c /home/vcap/app/gunicorn_config.py --error-logfile /home/vcap/logs/gunicorn_error.log -w 5 -b 0.0.0.0:$PORT wsgi command: scripts/run_app_paas.sh gunicorn -c /home/vcap/app/gunicorn_config.py --error-logfile /home/vcap/logs/gunicorn_error.log -w 5 -b 0.0.0.0:$PORT application
services: services:
- notify-aws - notify-aws
- notify-config - notify-config

View File

@@ -1,7 +1,7 @@
--- ---
buildpack: python_buildpack buildpack: python_buildpack
command: scripts/run_app_paas.sh gunicorn -w 5 -b 0.0.0.0:$PORT wsgi command: scripts/run_app_paas.sh gunicorn -w 5 -b 0.0.0.0:$PORT application
services: services:
- notify-aws - notify-aws
- notify-config - notify-config

14
wsgi.py
View File

@@ -1,14 +0,0 @@
import os
from flask import Flask
from whitenoise import WhiteNoise
from app import create_app
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'app', 'static')
STATIC_URL = 'static/'
app = Flask('app')
create_app(app)
application = WhiteNoise(app, STATIC_ROOT, STATIC_URL)