Fixes all the paths and routing errors

This commit is contained in:
Aaron Louie 2020-05-24 23:09:12 -04:00
parent d9d1367556
commit cb2613feee
5 changed files with 26 additions and 4 deletions

View File

@ -23,8 +23,8 @@ WORKDIR /app
ENV FLASK_APP=/app/crc/__init__.py
# Don't run gunicorn until the DC/OS container actually starts.
# Otherwise, environment variables will not be availabele.
# Otherwise, environment variables will not be available.
#CMD ["pipenv", "run", "gunicorn", \
# "--bind", "0.0.0.0:8000", \
# "-e", "SCRIPT_NAME=/api", \
# "crc:app"]
# "wsgi:app"]

View File

@ -37,6 +37,7 @@ pandas = "*"
xlrd = "*"
ldap3 = "*"
gunicorn = "*"
werkzeug = "*"
[requires]
python_version = "3.7"

3
Pipfile.lock generated
View File

@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "5363eb56e2e1622e2c443647fdf0b1963f3d0ee7b25c61f7065a542e546ece5b"
"sha256": "fad2f86b02a85b074e8ff9d8f3822784444d0925b0bf4227d4b26bbff1c45c2f"
},
"pipfile-spec": 6,
"requires": {
@ -863,6 +863,7 @@
"sha256:2de2a5db0baeae7b2d2664949077c2ac63fbd16d98da0ff71837f7d1dea3fd43",
"sha256:6c80b1e5ad3665290ea39320b91e1be1e0d5f60652b964a3070216de83d2e47c"
],
"index": "pypi",
"version": "==1.0.1"
},
"xlrd": {

View File

@ -18,4 +18,4 @@ if [ "$RESET_DB" = "true" ]; then
pipenv run flask load-example-data
fi
pipenv run gunicorn -e SCRIPT_NAME="$APPLICATION_ROOT" --bind 0.0.0.0:$PORT0 run:app
pipenv run gunicorn -e SCRIPT_NAME="$APPLICATION_ROOT" --bind 0.0.0.0:$PORT0 wsgi:app

20
wsgi.py Normal file
View File

@ -0,0 +1,20 @@
from werkzeug.exceptions import NotFound
from werkzeug.middleware.dispatcher import DispatcherMiddleware
from werkzeug.middleware.proxy_fix import ProxyFix
from crc import app
if __name__ == "__main__":
def no_app(environ, start_response):
return NotFound()(environ, start_response)
# Remove trailing slash, but add leading slash
base_url = '/' + app.config['APPLICATION_ROOT'].strip('/')
app.wsgi_app = DispatcherMiddleware(no_app, {app.config['APPLICATION_ROOT']: app.wsgi_app})
app.wsgi_app = ProxyFix(app.wsgi_app)
flask_port = app.config['FLASK_PORT']
app.run(host='0.0.0.0', port=flask_port)