【发布时间】:2012-11-13 09:07:11
【问题描述】:
下面是我的app.yaml 文件的代码。如果我去localhost:8080/ 我的index.app 加载正确。如果我转到localhost:8080/index.html,我会收到 404 错误。如果我转到任何其他页面,例如localhost:8080/xxxx,not_found.app 会正确加载。为什么我在 /index\.html 案例中收到 404 错误?
谢谢!
application: myapp
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /index\.html
script: index.app
- url: /
script: index.app
- url: /assets
static_dir: assets
- url: /*
script: not_found.app
libraries:
- name: jinja2
version: latest
index.py 中的代码
类 MainPage(webapp2.RequestHandler):
def get(self):
模板 = jinja_environment.get_template('index.html')
self.response.out.write(template.render(template_values))
app = webapp2.WSGIApplication([('/', MainPage)],
debug=True)
修复位于粗体文本中!
【问题讨论】:
-
你为什么要转义'.'?
-
我以为用的是正则表达式引用,所以需要转义句号来抑制特殊含义。
-
index.app中的处理程序是什么样的? -
对于 jinja2,应该从代码中引用 html,不是吗? "jinja.render_template("index.html")"
标签: python google-app-engine python-2.7 yaml