librelist archives

« back to archive

route match to any url

route match to any url

From:
weasky
Date:
2010-07-25 @ 03:03
Hi,

Is it possible to use the route decorator to match any url?

for example:

@app.route('/<path:path>')
def path(path):
    pass

however, the '/' won't be able to captured.

Thanks,
YC

Re: [flask] route match to any url

From:
Simon Sapin
Date:
2010-07-25 @ 07:55
Le 25/07/2010 05:03, weasky a écrit :
> @app.route('/<path:path>')
> def path(path):
>     pass
>
> however, the '/' won't be able to captured.
>

Hi,

Try this:

@app.route('/')
@app.route('/<path:path>')
def path(path=''):
     path = '/' + path # if you want the full path

Regards,
-- 
Simon Sapin