On Monday, November 20, 2017 at 7:04:00 PM UTC-8, Ian W. Scott wrote:
>
> I'm not getting web2py's 404 page because it's not the controller's page 
> that isn't found. It's the stylesheet. 
>

Yeah, I just was about to admit I didn't try messing with anything from 
static.
 

> So when I view all of the file requests in Chrome's dev tools (network 
> tab) I see that the request for the stylesheet has returned 404. The 
> requested URL was:
>
> http://127.0.0.1:8000/paideia/static/css/theme.1511232931.css  (Paideia 
> is the name of the app).
>
> Is that the problem? Does web2py's rewrite system only work for the 
> controller functions, but not for static files?
>
>
Well, the default "static file versioning" works for static files, but I've 
forgotten where that is handled.

/dps
 

> On Monday, November 20, 2017 at 9:55:09 PM UTC-5, Dave S wrote:
>>
>>
>>
>> On Monday, November 20, 2017 at 6:02:38 PM UTC-8, Ian W. Scott wrote:
>>>
>>> Yes, that's right. I'm getting a 404 on each file with the added version 
>>> string, which must mean that the routes.py isn't pointing the browser 
>>> successfully to the real file (without the version string in the name.
>>>
>>> For clarity's sake, here's the contents of my routes.py with the one 
>>> syntax error fixed:
>>>
>>> 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]
>>>
>>> I fixed the syntax error, but I'm still getting 404 errors.
>>>
>>
>>
>> Does your 404 page show the URL?  The default web2py 404 will show either 
>> invalid controller or invalid function, but not invalid application.
>>
>> /dps
>>
>>
>>> On Monday, November 20, 2017 at 8:38:17 PM UTC-5, Dave S wrote:
>>>>
>>>>
>>>>
>>>> On Monday, November 20, 2017 at 9:04:27 AM UTC-8, Ian W. Scott wrote:
>>>>>
>>>>> 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.
>>>>>
>>>>
>>>> I tried to run the doctests on rewrite.py, but didn't do it right to 
>>>> get the gluon imports working.  The module doesn't seem 
>>>>
>>>> Is the error that you're not getting the files you expect?  Are you 
>>>> getting a 404 as a result?
>>>>
>>>> /dps
>>>>
>>>>  
>>>>
>>>>>
>>>>> 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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to