我的 .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 将无法加载。
我知道这可能是我的一些愚蠢的疏忽,我在谷歌或这个网站上找不到任何帮助。感谢您的任何帮助。
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题在于您的应用程序定义。
有关此内容的文档位于此处,尽管它没有“简单”示例。
http://code.google.com/appengine/docs/python /tools/webapp/running.html
请注意,您不需要使用 .html。相反,您可以在这两个地方映射“/user”。
The issue is with your application definition.
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.