Flask redirecting multiple routes

前端 未结 4 875
北恋
北恋 2021-01-30 10:49

I\'m trying to implement a redirecting pattern, similar to what StackOverflow does:

@route(\'///\')
@route(\'//\')
de         


        
4条回答
  •  再見小時候
    2021-01-30 11:37

    Well, it looks like my original code actually worked. Flask-Classy was the issue here (and since this question has a bounty, I can't delete it).

    I forgot that Flask-Classy renames routes, so instead of url_for('ClassName:profile'), I'd have to select the outermost decorator's route:

    url_for('ClassName:profile_1')
    

    An alternative would be to explicitly specify an endpoint to the route:

    @route('///', endpoint='ClassName:profile')
    

提交回复
热议问题