我的 .yaml 未正确重定向

发布于 2024-09-25 11:13:42 字数 1357 浏览 5 评论 0原文

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 将无法加载。

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

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 works, 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷路的信 2024-10-02 11:13:42

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

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

有关此内容的文档位于此处,尽管它没有“简单”示例。
http://code.google.com/appengine/docs/python /tools/webapp/running.html

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文