are routes run only after clicking submit button? I want to run routes from other route function not by clicking submit button. I am doing like this because ajaxCall route only running function not rendering template
from flask import Flask,render_template,send_file
app = Flask(__name__)
@app.route("/ajaxCall")
def home():
# some code
# i want to call @app.route("/name") here
return render_template('home.html')
@app.route("/name")
def name():
# some code
return render_template('name.html')
if __name__=='__main__':
app.run(debug=True,port=5002)
You can use redirect
function. Just redirect from /ajaxCall
to name
like this:
from flask import Flask,render_template,send_file, redirect
app = Flask(__name__)
@app.route("/ajaxCall")
def home():
# some code
# i want to call @app.route("/name") here
return redirect('/name')
# This will run your name route
return render_template('home.html')
@app.route("/name")
def name():
# some code
return render_template('name.html')
if __name__=='__main__':
app.run(debug=True,port=5002)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.