my app.yaml
:
handlers:
- url: /static
static_dir: static
- url: /.*
script: main.app
is there a way, inside my webapp2 code, to get the absolute URL of the /static
route?
When you define routes in your application you can compute an uri. See: http://webapp-improved.appspot.com/guide/routing.html#building-uris With this information and your knowledge of the app.yaml you can compute the uri for the static url.
In your main.app you add a dummy route definition for static. It will only be used to build the uri and it will never be used for routing.
Modified example from the webapp2 docs :
app = webapp2.WSGIApplication([
webapp2.Route('/', handler='HomeHandler', name='home'),
webapp2.Route('/static', handler=HomeHandler, name='static'), # never used for routing
])