Oups, I posted the solution a bit too quickly. It indeeds work on the local dev_appserver, but it failed when being uploaded :
Error 400: --- begin server output --- Could not compile RE "/(.+?)/static/_(\\d+\\.\\d+\\.\\d+)\\/(?!error_handlers)(.+)": invalid perl operator: (?! If anybody knows how to allow access of only a part of the static folder to the application on GAE, I'm interested to hear about it. Best regards, -Mathieu On Tue, May 24, 2016 at 12:38 PM Mathieu Clabaut <math...@clabaut.net> wrote: > Hello, > > I had some difficulties to set up some "routes_onerror" files on GAE. It > worked perfectly on a local instance, but each time an HTTP exception was > raised, GAE issued a "file inaccessible" error (status 500). > > The problem comes from the fact that static files are treated specially > on GAE and are by default not counted in the applicatin quota and not > accessible to the application. One solution is the to add > "application_readable: true" to the static url handler in the app.yaml > file. But doing this, all static files are counted in the quota. > > We however can not put the error files outside of the static directory, > where web2py expect them. > > So, my solution is : > In the routes.py put something like: > routes_onerror= ( > ('*/503', '/appname/static/_0.0.0/error_handlers/503.html'), > ('*/404', '/appname/static/_0.0.0/error_handlers/404.html'), > ('*/*', '/appname/static/_0.0.0/error_handlers/default_error.html'), > ) > > (suppress _0.0.0/ if you don't use static asset management). > And in the app.yaml: > - url: /(.+?)/static/_(\d+\.\d+\.\d+)\/error_handlers/(.+) > static_files: applications/\1/static/error_handlers/\3 > upload: applications/(.+?)/static/error_handlers/(.+) > secure: optional > expiration: "365d" > application_readable: true > > - url: /(.+?)/static/_(\d+\.\d+\.\d+)\/(?!error_handlers)(.+) > static_files: applications/\1/static/\3 > upload: applications/(.+?)/static/(?!error_handlers)(.+) > secure: optional > expiration: "365d" > > Note the use of (?!…) to prevent the regexp to match our error handlers > file. > If you don't use static asset management, the code would be : > > - url: /(.+?)/static/error_handlers/(.+) > static_files: applications/\1/static/error_handlers/\2 > upload: applications/(.+?)/static/error_handlers/(.+) > secure: optional > application_readable: true > > - url: /(.+?)/static/(?!error_handlers)(.+) > static_files: applications/\1/static/\2 > upload: applications/(.+?)/static/(?!error_handlers)(.+) > secure: optional > > See > https://cloud.google.com/appengine/docs/python/config/appref#handlers_element > for documentation about "application_readable" parameter. > > Hope this may help others. > > -Mathieu > > > -- 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.