Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how flask match list or return 404

I am newbee to Flask from perl.

Now as following I want to match by below route only for url list [/list/user, list/course, list/teacher, …], if request url such as "list/fxxk" will get 404. How to achieve this in a smart way.

Thanks to anyone if any help.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

@app.route('/list/<object>')
def list_object(object):
    # list all the object from DB
    return object

I think I can do a match inside the function. I want to know if there is any elegant to do this.

>Solution :

Try flasks any converter:

@app.route('/list/<any(user, course, teacher):object>')
def list_object(object):
    # list all the object from DB
    return object
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading