LA_
LA_

Reputation: 20419

How to create css folder working both locally and thru GAE?

I have the following folders structure:

project-folder
 - templates
   - css
     vk.css
   index.html
 app.yaml
 script.py

I would like to be able:

  1. run index.html without GAE
  2. run index.html thru GAE (referenced at script.py as templates/index.html)

In both cases vk.css should be used. How should I define that at app.yaml and at index.html? Url is http://localhost:8080/something/.

I've made it working with GAE, index.html:

<link type="text/css" href="/css/vk.css" rel="stylesheet" />    

app.yaml:

- url: /css/
  static_dir: templates/css  

But it doesn't work locally.

Upvotes: 0

Views: 178

Answers (1)

Nick Johnson
Nick Johnson

Reputation: 101149

If you want your browser to be able to render the template directly off the filesystem, you can't use site-relative URLs (eg, ones that begin with a /) - when reading off your filesystem, site relative URLs are relative to your filesystem root. Instead, use relative urls (eg, ../css/vk.css), and make sure that the filesystem structure matches your URL structure.

Upvotes: 1

Related Questions