Friday 15 June 2012

My google app engine website is only displaying my main page after migrating to python 2.7 -



My google app engine website is only displaying my main page after migrating to python 2.7 -

can give me pointers on how other pages show? main.py

import webapp2 import os import jinja2 jinja_environment = jinja2.environment(autoescape=true, loader=jinja2.filesystemloader(os.path.join(os.path.dirname(__file__)))) class mainpage(webapp2.requesthandler): def get(self): template = jinja_environment.get_template('index.html') self.response.write(template.render()) application = webapp2.wsgiapplication([ ('/',mainpage), ], debug=true)

and app.yaml

application: ftmyersptcong version: 1 runtime: python27 api_version: 1 threadsafe: true libraries: - name: jinja2 version: latest handlers: - url: /styles static_dir: styles - url: /images static_dir: images - url: /scripts static_dir: scripts - url: /.* script: main.application

i maintain getting 404 not found page when click on of links other pages have been href'd in html code. in log:

info 2014-11-12 18:15:42,434 module.py:652] default: "get / http/1.1" 500 - info 2014-11-12 18:28:21,151 module.py:652] default: "get / http/1.1" 200 1274 info 2014-11-12 18:28:21,272 module.py:652] default: "get /styles/main.css http/1.1" 200 1880 info 2014-11-12 18:28:27,512 module.py:652] default: "get /downloads.html http/1.1" 404 154

you have handful of static directory routes defined in app.yaml (images, scripts, styles) -- that's why css file loading fine, example. have not matching directories going "application" in "main.py" file.

in there, defining 1 route -- "/" , mainpage defined handler route. calls "/downloads.html" sent same router, since doesn't match "/" route, 404 returned.

you need define other route(s) , handlers in main.py. example:

application = webapp2.wsgiapplication([ ('/',mainpage), ('/downloads.html',downloadpage) ], debug=true)

then you'd define downloadpage mainpage handle route. can pattern matches in route definition in order pass along variable info, example, above should work.

python google-app-engine python-2.7

No comments:

Post a Comment