def test_view_patients_invalid_jwt(): jwt = "1nv4l1DJwT" header = {'Authorization': "Bearer {token}".format(token=jwt)} patients = invoke_service(service="backend", page_name="view_patients", headers=header) return render_template('view_patients.html', patients=patients)
def update_medical_history(id): patient = invoke_service(page_name="update_medical_history", id=id, service="admin-backend", headers=session["jwt_header"]) form = PatientForm(request.form) try: form.fname.data = patient['fname'] form.lname.data = patient['lname'] form.age.data = patient['age'] form.weight.data = patient['weight'] except TypeError: return patient if request.method == 'POST' and form.validate(): admin_backend_url = create_url_for_service("update_medical_history", id, service="admin-backend") response = requests.post(admin_backend_url, data=request.form, headers=session["jwt_header"]) if response.text == "redirect": flash('Patient updated', 'success') return redirect(url_for('view_patients')) return render_template('update_medical_history.html', form=form)
def view_medical_history(id): patient = invoke_service(service="backend", page_name="view_medical_history", id=id, headers=session["jwt_header"]) return render_template('view_medical_history.html', id=patient['id'], fname=patient['fname'], lname=patient['lname'], age=patient['age'], conditions=patient['conditions'], weight=patient['weight'])
def login(): if request.method == "POST": username = request.form['username'].lower() password = request.form['password'] users = invoke_service(page_name="view_users", service="utils-backend") try: username = users[username] if username[password] != password: raise KeyError("Password was incorrect") role = username["role"] except KeyError: return render_template("login.html", msg="Incorrect username or password...") session['logged_in'] = True session["jwt_header"] = get_header_for_auth(role=role) return render_template("index.html", msg="You have been logged in...") return render_template("login.html")
def view_patients(): patients = invoke_service(service="backend", page_name="view_patients", headers=session["jwt_header"]) return render_template('view_patients.html', patients=patients)
def populate_db(): invoke_service(page_name="db/populate", service="utils-backend") return render_template("index.html", msg="DB has been populated.")
def test_view_users(): users = invoke_service(page_name="view_users", service="utils-backend") return jsonify(users)
def hello_world(): response = invoke_service(service="backend", page_name="hello_world") return render_template('index.html', msg=response['message'])
def go_response(): return jsonify(invoke_service(service="go-service").content.decode())
def javascript_response(): return jsonify(invoke_service(service="javascript-service"))