I have a working flask app set up with a HTML page. The problem is that in my HTML, where I have {{ Appointments }}
, it always shows the value of the second render_template
, of an empty list.
@app.route("/PatientDashboard.html", methods=["GET", "POST"])
def PatientDashboard():
if request.method == "POST":
Date = request.form.get("Date")
print(Date)
return render_template("PatientDashboard.html", Appointments=["This should show up."])
else:
return render_template("PatientDashboard.html", Appointments=[])
The problem is that the first render_template
is never expressed. Why is this and how would I solve it?
Thank you ever so much in advance.
EDIT 1:
Relevant HTML is below.
<script>
var jsDate = $('#calendar').datepicker({
inline: true,
firstDay: 1,
showOtherMonths: false,
dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
onSelect: function(dateText, inst) {
document.getElementById("Date").innerHTML = dateText;
$.ajax({
type: 'POST',
url: "{{ url_for('PatientDashboard') }}",
data: {Date: dateText},
dataType: "text",
});
}
});
</script>
Further on I have the {{ Appointments }}
in a divider.