views:

136

answers:

1

My simple GAE app is not redirecting to the /static directory for requests when url is multiple levels.

Dir structure:

 /app/static/css/main.css

App:

I have two handlers one for /app and one for /app/new

app.yaml:

handlers:

- url: /static
  static_dir: static

- url: /app/static/(.*)
  static_dir: static\1

- url: /app/.*
  script: app.py
  login: required

HTML:

Description: When page is loaded from /app HTTP request for main.css is successful

 GET /static/css/main.css

But when page is loaded from /app/new I see the following request:

GET /app/static/css/main.cs

That's when I tried adding the /app/static/(.*) in the app.yaml but it is not having any effect.

A: 

In HTML an internal link starting with "/" is an absolute link, a link starting without a "/" is a relative link. So if you are requesting:

/app

and have a relative link:

static/css/main.css

the request becomes:

/static/css/main.css

the relative link uses the "/" in "/app" because the "app" part is considered to be the page and the "/" is considered to be the directory.

If you are requesting:

/app/new

Your request becomes:

/app/static/css/main.css

the relative link uses the "/app/" because "/app/" is considered the directory and "new" is considered the page.

Peter Farmer