Pass parameters between flask @app.route('/page') Pass parameters between flask @app.route('/page') flask flask

Pass parameters between flask @app.route('/page')


You can either allow the user to pass the value to the function via the URL, or you can call Random inside Help:

@app.route('/help/<random>')def Help(random):    return render_template("help.html", PassingRandom=random)

Or, by calling the function Random in Help:

@app.route('/help')def Help():   PassingRandom = Random()   return render_template("help.html", PassingRandom=PassingRandom)


Whoa... I'd strongly advise on going through a few tutorials on Flask- But just to give a quick explanation.

First off, you never declared your app.

Secondly, you're not supposed to (generally) call your @app.route function directly. The general idea is that you reach the function through going through a url (in your case /help).

If you want the same random value throughout your whole app, then yes, a global variable is the answer. If you want it to change every time you access /help, just call random from there.

By the way, just a bit of PEP8 to brighten the day- function/variable names should be lowercase, and don't use names that are the same as module names (e.g. Random)