I have a file.html which contains the following code
{%extends "base.html"%}
{%block content%}
<p>Done predicting</p>
<div>
<p>Choose files to view results</p>
<label for="txt_file">txt file</label>
<input type="file" id="txt_file">
<label for="ann_file">ann file</label>
<input type="file" id="ann_file">
<button type="button" onclick="processFile()">Display</button>
<script>
function processFile() {
var t = document.getElementById("txt_file").value;
var a = document.getElementById("ann_file").value;
window.location.href='{{url_for('display',txt=t,ann=a)}}';
}
</script>
</div>
{%endblock%}
In my routes.py I have the function
@app.route("/display/<txt>/<ann>")
def display(txt,ann):
return txt + " " + ann
When I pass {{url_for('display',txt='somefile.txt',ann='somefile.ann')}}
manually I get the url /display/somefile.txt/somefile.ann, otherwise it gives /display//. Can anyone help? Or is there a better way to do this?