我的.yaml没有正确重定向

时间:2010-10-02 03:46:32

标签: python google-app-engine yaml

的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()

我目前正在使用Google App Engine离线测试。当我去localhost:8080时,它会把我带到我的登录页面。但是,当我尝试访问localhost:8080 / users.html时,它不会加载我的main.py文件(它会像链接断开一样出错)。如果我交换网址,main.py有效,但login.py将无法加载。

我知道这可能是我的一些愚蠢的疏忽,我在谷歌或这个网站上找不到任何帮助。谢谢你的帮助。

1 个答案:

答案 0 :(得分:2)

问题在于您的应用程序定义。

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

关于这个的文档在这里,虽然它没有“简单”的例子。 http://code.google.com/appengine/docs/python/tools/webapp/running.html

只需注意,您不需要使用.html。相反,您可以在两个地方映射'/ user'。

相关问题