0

So Im calling a flask function which takes one parameter check from my html code, im getting the error: TypeError: categories_html() missing 1 required positional argument: 'check'.

Heres my Python code:

app.route('/cat_html', methods=['GET'])
def categories_html(check):
    if session.get('teacher_name'):
        return trav0.gen(check)

    else:
        return redirect('/teachers')

And then here is the html call:

<li class="nav-item">
    <a class="navbar-brand" href="{{ url_for('categories_html', check='sta10') }}" target="_blank" style="color:31708f;">Tasks</a>
</li>

So trav0.gen generates a html, check is simply equal to a number, depending on the number a different html is generated.

0

1 Answer 1

0

It's not 100% clear what you want the url to look like for cat_html.

You can do a couple things.

For a url like /cat_html/sta10 you would write the method like:

@app.route('/cat_html/<check>', methods=['GET'])
def categories_html(check):
    # use check here
    return check

check will be part of the url path.

To pass check as a query parameter with a url like /cat_html/?check=sta10, you don't add it as parameter to the function, you get() it in the function:

@app.route('/cat_html/', methods=['GET'])
def categories_html():
    check = request.args.get('check', '')
    # use check here
    return check
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.