I have the following Flask interface.py
from flask import Flask, request, render_template, redirect
app = Flask( __name__)
@app.route("/")
def index(message=None):
return render_template('home.html', message=message)
@app.route("/viewer", methods=['POST'])
def viewer():
chr = request.form['chr']
print("chr %s"%chr)
return render_template('viewer.html', chr=chr)
home.html
[...]
<form id="inForm" action="/viewer" method="post" enctype="multipart/form-data">
<div class="form-group">
<select name="chr" required>
<option value=""></option>
<option value="all">all</option>
<option value="chrM">chrM</option>
<option value="chr1">chr1</option>
</select>
</div>
</form>
viewer.html
<body>
{{ chr }}
<script type="module">
var chr_g = {{ chr }};
console.log("chr_g " + chr_g)
</script>
</body>
In home.html
I choose chr = chrM
, then submit and the viewer.html
is loaded.
chr
is correctly displayed in the html section, but in the JS console I get:
Uncaught ReferenceError: chrM is not defined
<anonymous> http://localhost:5000/viewer:25
I've followed the answer given in this question, with no luck. Any idea what I am missing?
Thank you for any help you can provide