开发者

My .yaml is not redirecting properly

app.yaml

application: classscheduler9000
version: 1
runtime: python
api_version: 1

handlers:   
- url: /static
  static_dir: static

- url: /images
  static_dir: static/images

- url: /stylesheets
  static_dir: static/stylesheets

- url: /users\.html
  script: main.py

- url: /.*
  script: login.py

main.py

import hashlib

from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db

class AccountHolder(db.Model):
    ...

class MainPage(webapp.RequestHandler):
    def get(self):
            ...

class UserWrite(webapp.RequestHandler):
    def post(self):
        ...

application = webapp.WSGIApplication(
                                     [('/', MainPage),
                                      ('/sign', UserWrite)],
                                     debug=True)

def getMD5Hash(textToHash=None):
    return hashlib.md5(textToHash).hexdigest()

def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()

I'm currently testing this offline with Google App Engine. When I go to localhost:8080, It takes me to my login page. However, when I try to access localhost:8080/users.html, it doesn't load my main.py file (It errors out like a broken link). If I swap the urls, main.py wor开发者_StackOverflow中文版ks, but login.py won't load.

I know this is probably some stupid oversight on my part, and I couldn't find any help on google or this site. Thanks for any help.


The issue is with your application definition.

application = webapp.WSGIApplication([('/user\.html', MainPage),
                                      ('/sign', UserWrite)],
                                     debug=True)

The documentation about this is here, although it does not have "simple" examples. http://code.google.com/appengine/docs/python/tools/webapp/running.html

Just a note, you do not need to use the .html. Instead you can map '/user' in both places.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜