Apparently, APPLICATION_ROOT does something.

This commit is contained in:
Aaron Louie 2020-05-24 00:05:24 -04:00
parent 4c88afbdd3
commit 8fa36b968c
3 changed files with 13 additions and 13 deletions

20
app.py
View File

@ -55,7 +55,7 @@ else:
app.config.root_path = app.instance_path
app.config.from_pyfile('config.py', silent=True)
conn.add_api('api.yml', base_path=app.config['BASE_HREF'] + 'pb')
conn.add_api('api.yml', base_path='/pb')
db = SQLAlchemy(app)
migrate = Migrate(app, db)
ma = Marshmallow(app)
@ -83,7 +83,7 @@ def has_no_empty_params(rule):
return len(defaults) >= len(arguments)
@app.route(app.config['BASE_HREF'] + '/site_map')
@app.route('/site_map')
def site_map():
links = []
for rule in app.url_map.iter_rules():
@ -103,15 +103,15 @@ from models import Study, RequiredDocument, Investigator, StudySchema, RequiredD
StudyDetails, StudyDetailsSchema
@app.route(app.config['BASE_HREF'] + '/', methods=['GET', 'POST'])
@app.route('/', methods=['GET', 'POST'])
def index():
# display results
studies = db.session.query(Study).order_by(Study.DATE_MODIFIED.desc()).all()
table = StudyTable(studies)
return render_template('index.html', table=table, BASE_HREF=app.config['BASE_HREF'])
return render_template('index.html', table=table, APPLICATION_ROOT=app.config['APPLICATION_ROOT'])
@app.route(app.config['BASE_HREF'] + '/new_study', methods=['GET', 'POST'])
@app.route('/new_study', methods=['GET', 'POST'])
def new_study():
form = StudyForm(request.form)
action = "/new_study"
@ -129,7 +129,7 @@ def new_study():
description_map=description_map)
@app.route(app.config['BASE_HREF'] + '/study/<study_id>', methods=['GET', 'POST'])
@app.route('/study/<study_id>', methods=['GET', 'POST'])
def edit_study(study_id):
study = db.session.query(Study).filter(Study.STUDYID == study_id).first()
form = StudyForm(request.form, obj=study)
@ -150,7 +150,7 @@ def edit_study(study_id):
description_map={})
@app.route(app.config['BASE_HREF'] + '/investigator/<study_id>', methods=['GET', 'POST'])
@app.route('/investigator/<study_id>', methods=['GET', 'POST'])
def new_investigator(study_id):
form = InvestigatorForm(request.form)
action = "/investigator/" + study_id
@ -170,14 +170,14 @@ def new_investigator(study_id):
description_map={})
@app.route(app.config['BASE_HREF'] + '/del_investigator/<inv_id>', methods=['GET'])
@app.route('/del_investigator/<inv_id>', methods=['GET'])
def del_investigator(inv_id):
db.session.query(Investigator).filter(Investigator.id == inv_id).delete()
db.session.commit()
return redirect('/')
@app.route(app.config['BASE_HREF'] + '/del_study/<study_id>', methods=['GET'])
@app.route('/del_study/<study_id>', methods=['GET'])
def del_study(study_id):
db.session.query(RequiredDocument).filter(RequiredDocument.STUDYID == study_id).delete()
db.session.query(Investigator).filter(Investigator.STUDYID == study_id).delete()
@ -212,7 +212,7 @@ def _update_study(study, form):
db.session.commit()
@app.route(app.config['BASE_HREF'] + '/study_details/<study_id>', methods=['GET', 'POST'])
@app.route('/study_details/<study_id>', methods=['GET', 'POST'])
def study_details(study_id):
study_details = db.session.query(StudyDetails).filter(StudyDetails.STUDYID == study_id).first()
if not study_details:

View File

@ -11,7 +11,7 @@ DEVELOPMENT = environ.get('DEVELOPMENT', default="true") == "true"
TESTING = environ.get('TESTING', default="false") == "true"
# Add trailing slash to base path
BASE_HREF = re.sub(r'//', '/', '/%s/' % environ.get('BASE_HREF', default="/").strip('/'))
APPLICATION_ROOT = re.sub(r'//', '/', '/%s/' % environ.get('APPLICATION_ROOT', default="/").strip('/'))
DB_HOST = environ.get('DB_HOST', default="localhost")
DB_PORT = environ.get('DB_PORT', default="5432")
@ -28,4 +28,4 @@ print('=== USING DEFAULT CONFIG: ===')
print('DB_HOST = ', DB_HOST)
print('DEVELOPMENT = ', DEVELOPMENT)
print('TESTING = ', TESTING)
print('BASE_HREF = ', BASE_HREF)
print('APPLICATION_ROOT = ', APPLICATION_ROOT)

View File

@ -2,7 +2,7 @@
<html lang="en">
<head>
<title>Protocol Builder Mock</title>
<base href="{{ BASE_HREF }}">
<base href="{{ APPLICATION_ROOT }}">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="https://use.typekit.net/kwp6dli.css">
{% assets 'app_scss' %}