1

I am trying to make a basic application that would make my index.html file run offline - when no internet is available. I am using Google App Engine, Webapp2 and Jinja2. Would you suggest a better framework for an offline website / webapp.

When I run this application I get this console error:

Creating Application Cache with manifest http://localhost:9080/static/cache.manifest localhost/:1
Application Cache Checking event localhost/:1
Application Cache Downloading event localhost/:1
Application Cache Progress event (0 of 1) http://localhost:9080/index.html localhost/:1
Application Cache Error event: Resource fetch failed (404) http://localhost:9080/index.html 

I used the following:

Files

static/cache.manifest
main.py
index.html
app.yaml

main.py

import os, webapp2, jinja2

JINJA_ENVIRONMENT = jinja2.Environment(
    loader=jinja2.FileSystemLoader(os.path.dirname(__file__)))

class Home(webapp2.RequestHandler):
    def get(self):
        template = JINJA_ENVIRONMENT.get_template('index.html')
        self.response.write(template.render())

app = webapp2.WSGIApplication([('/', Home),
                              ], debug=True)

index.html

<!DOCTYPE html>
<html manifest="/static/cache.manifest">
    <head>
    </head>
    <body>
        Hello World
    </body>
</html>

cache.manifest

CACHE MANIFEST
/index.html

app.yaml

application: formetoteston
version: 1
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /static/(.*\.(appcache|manifest))
  mime_type: text/cache-manifest
  static_files: static/\1
  upload: /static/(.*\.(appcache|manifest))
  expiration: "0m"

- url: .*
  script: main.app

libraries:
- name: webapp2
  version: "2.5.2"

- name: jinja2
  version: "2.6"
Karl Stulik
  • 961
  • 1
  • 12
  • 24

1 Answers1

0

I found it! I needed to add the proper URL handlers in app.yaml. Except I moved my index.html to /static.

application: formetoteston
version: 1
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: static/(cache.manifest)
  mime_type: text/cache-manifest
  static_files: static/cache.manifest
  upload: static/(cache.manifest)

- url: static/(.*)
  static_files: static/index.html
  upload: static/index.html

- url: .*
  script: main.app

libraries:
- name: webapp2
  version: "2.5.2"

- name: jinja2
  version: "2.6"
Karl Stulik
  • 961
  • 1
  • 12
  • 24