Steve
Steve

Reputation: 1459

Moving HTML files to their own directory in Google App Engine (Using Jinja2 Templates) - Error 13

This seems like its probably something simple and n00bish, but I can't move my .html files to their own directory without the site coming to a screaming halt. They work file if left in the root folder.

Here's what I tried to do

<root>
|_ app.yaml
|_ main.py
|_ ...etc
|_<layout>
  |_ base.html
  |_ home.html
  |_ ...etc

I added the following to my app.yaml file:

- url: /layout
  static_dir: layout

I figured that would do it, and since nothing else uses that directory I assume the order in HANDLERS doesn't matter. Here is my complete handlers section in case someone spots something obvious I missed (I admit to not having a great understanding of this, despite having trolled through documentation and other problems here relating to static files and directories):

handlers:
- url: /favicon.ico
  static_files: favicon.ico
  upload: favicon.ico

- url: /layout
  static_dir: layout

- url: /stylesheets
  static_dir: stylesheets

- url: .*
  script: main.app

I've tried mixing up the order of the handlers, but the error is always the same:

IOError: [Errno 13] file not accessible: 'E:\\Users\\Steve\\Documents\\test_gae\\test\\layout\\home.html'

Any suggestions would be greatly appreciated, Cheers

ANSWER, as per the answer from voscausa: these HTML files are templates, not static pages. Removing the static handler for 'layout' completely solved the problem.

Upvotes: 0

Views: 235

Answers (1)

voscausa
voscausa

Reputation: 11706

If you use Jinja2, you do not need to put the /layout folder in your app.yaml, because you do not serve the templates static, but you render the templates with jinja and write the response HTML.

So the problem must be in your code. Look at the template path.

The order of handler matters. The url patterns are matched from top to bottom. This means

- url: /.*
  script: main.app

is always the last handler!!

Upvotes: 2

Related Questions