There are some ways.
Pass the url function by paramter:
Python Code:
@app.route('/', methods = ['GET', 'POST'])
def index():
return render_template("main.html", var_home = url_for('home_func'))
@app.route('/home', methods = ['GET', 'POST'])
def home_func():
return render_template("test1.html")
HTML Code:
<button id="Enter" type="button" onclick="window.location.href = '{{ var_home }}' ; " class="button">Enter</button>
You could use url_for.. instead of the variable name on the button aswell. Like So:
Python Code:
@app.route('/', methods = ['GET', 'POST'])
def index():
return render_template("main.html")
@app.route('/home', methods = ['GET', 'POST'])
def home_func():
return render_template("test1.html")
HTML:
<button id="Enter" type="button" onclick="window.location.href = '{{ url_for('home_func') }}' ; " class="button">Enter</button>
You can call the view function as well like so:
Python Code:
@app.route('/', methods = ['GET', 'POST'])
def index():
return render_template("main.html")
@app.route('/home', methods = ['GET', 'POST'])
def home_func():
return render_template("test1.html")
HTML:
<button id="Enter" type="button" onclick="window.location.href = '/home' ; " class="button">Enter</button>