I'm still wondering if anyone can help with this. I found a minor error in
the second member of the routes_in tuple (the period shouldn't be escaped).
But it's still not working for me. I used re.sub to confirm that the second
member *should be* outputting the right string. So far I'm just testing
this on the bundled rocket server, so I don't think there's any issue with
server settings.
Any help would be much appreciated.
On Friday, November 17, 2017 at 10:12:58 AM UTC-5, Ian W. Scott wrote:
>
> Hi there. I'm dynamically adding version numbers to the filenames for
> static assets like css, js, and image files. (These version numbers aren't
> actually in the filenames. They're just added to the url in the <link> and
> <script> tags that reference them.) So I need to use url rewriting to
> remove those version numbers. In other words, if the browser looks for
>
> /static/css/theme.1510773357.css
>
> it should be served
>
> /static/css/theme.css
>
> I've written a routes.py file that I thought would do the trick, but it's
> not working. The browser is still giving a 404 error for the file.
>
> routes_in = ((r
> '.*/static/(?P<subdir>(css|images|audio|js))/(?P<basename>.*)\.[\d]{10}\.(?P<extension>(css|js|ico|png|svg|jpe?g))'
> ,
> r'/static/\g<subdir>/\g<basename>\.\g<extension>'),
> )
> routes_out = [(x, y) for (y, x) in routes_in]
>
> Any idea what's wrong? I've confirmed that the first regex in the pair
> does match the filename, and that the correct matching groups are found
> ({'subdir': 'css', 'basename': 'theme', 'extension': 'css'}). Is there
> something wrong with the second string that creates the new path?
>
> In case anyone is wondering, I'm doing this even though I know about
> web2py's built-in versioning system. The app is under constant incremental
> development and I don't want to have to manually change version numbers
> every time I push out an update. This approach automatically forces users
> to download the updated file based on its last-modified datetime.
>
> Thanks,
>
> Ian
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.