【发布时间】:2013-11-29 04:07:59
【问题描述】:
我是 Google App Engine 的新手,我正在尝试创建一个简单的多页应用程序(index.htm、sites.htm、topics.htm)。当我运行没有文件名的应用程序时,一切都很好http://localhost:9080。但是当我尝试加载特定页面 http://localhost:9080/index.htm 或 http://localhost:9080/sites.htm 或 http://localhost:9080/topics.htm 时,我收到 404 错误
这是我的 app.yaml
application: msa
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: /static
static_dir: static
- url: .*
script: main.app
libraries:
- name: webapp2
version: "2.5.2"
我的 MainHandler 如下
class MainHandler(webapp2.RequestHandler):
def get(self):
path = self.request.path
temp = os.path.join(os.path.dirname(__file__),'templates/' + path)
self.response.write(temp + '<br />')
if not os.path.isfile(temp):
temp = os.path.join(os.path.dirname(__file__),'templates/index.htm')
outstr = template.render(temp, { })
self.response.out.write(outstr)
app = webapp2.WSGIApplication([
('/', MainHandler)
], debug=True)
我所有的文件都是以这种方式组织的
/
/app.yaml
/index.yaml
/main.py
/static
/static/glike.css
/templates
/templates/_base.htm
/templates/index.htm
/templates/topics.htm
/templates/sites.htm
任何指导将不胜感激
【问题讨论】:
标签: google-app-engine python-2.7 webapp2 multipage