Re: [flask] Fwd: Recoverging the tail to an URL rule
- From:
- Oliver Berger
- Date:
- 2011-11-15 @ 21:45
I guess you want something like:
@app.route('/photos/<path:filepath>')
def show_file(filepath):
pass
found here http://flask.pocoo.org/docs/api/#url-route-registrations
regards
Oliver
On 15.11.2011 17:31, Juancarlo Añez wrote:
> Hello,
>
> I want to build with Flask a simple application that will show in a nice
> format the contents of a directory hierarchy filled with photographs.
>
> The issue i'm having is that what needs to be done for each directory
> and for each image is generic, but the application doesn't know what the
> directory structure is beforehand.
>
> Ideally, I would like to have RESTful URLs of the form:
>
> http://mysiste.org/photos/1999/november/amsterdam/
>
> or
>
> http://mysiste.org/photos/1999/november/amsterdam/IMG2502.jpg
>
>
> That could be handled by a single view function that understands that
> the the trailing "1999/november/amsterdam/" part is a parameter, but I
> don't know how to do that with simple @rule decorators.
>
> Since I can examine the complete directory structure periodically, I
> thought that I can do what I want by messing with the rules map
> periodically, mapping the restful URLs to the same view functions. I
> just think that being able to have a rule like "/photos/**" that gets
> the "**" as a parameter would be much more pythonic.
>
> Is there a way to do what I want with Flask?
>
> Thanks in advance,
>
> --
> Juancarlo *Añez*
>
>
>
>
> --
> Juancarlo *Añez*
>
Re: [flask] Fwd: Recoverging the tail to an URL rule
- From:
- Juancarlo Añez
- Date:
- 2011-11-16 @ 12:08
Oliver,
On Tue, Nov 15, 2011 at 17:15, Oliver Berger <oliver@digitalarchitekt.de>wrote:
> I guess you want something like:
>
> @app.route('/photos/<path:filepath>')
> def show_file(filepath):
> pass
>
Exactly!
Thanks. I'll make some experiments with and without trailing slashes to see
what happens.
>
> found here http://flask.pocoo.org/docs/api/#url-route-registrations
May I say that I found the docs lacking in examples about this feature?
Regards,
--
Juancarlo *Añez*