Python Forum
Problem with arguments in route function.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with arguments in route function.
#3
@app.route has a connection with function under.
Can not take in 1 value from route and have 2 argument in function.
Just to make it clear route is the url in address bar.
@app.route('/user/<user_name>')
def foo(user_name):
    user_name = user_name.capitalize()    
    return render_template('user.html', name=user_name)
Call this would be http://127.0.0.1:5000/user/kent

def foo(user_name, arg): would give your error.
Error:
TypeError: foo() missing 1 required positional argument: 'arg'
There are way to get several parameter from route or maybe you mean to get values from the web-site eg html form.
It more normal/better to keep route(url call) rather simple,if need many argumet do this in web-site.

Look here for some examples multiple parameters in route.
Reply


Messages In This Thread
RE: Problem with arguments in route function. - by snippsat - Aug-26-2019, 04:55 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  how to create dynamic arguments to be passed in jinja template in url_for function? experimental 1 2,762 May-01-2020, 05:50 PM
Last Post: Larz60+
  How to POST html data to be handled by a route endpoint nikos 1 2,373 Mar-07-2020, 03:14 PM
Last Post: nikos
  Problem enabling http auth in a route nikos 2 2,791 Mar-02-2019, 01:13 PM
Last Post: nikos
  Passing a query value from a Bottle html template to a route with an encoding nikos 0 2,913 Sep-30-2018, 03:29 AM
Last Post: nikos

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020