1
我是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错误MainHandler doe不处理所有页面请求 - Google App Engine
这里是我的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
任何指导,将不胜感激
我可以创建通用路由到在一个处理程序中处理* .htm之类的东西? – user3047955
我已经更新了我的答案。 – voscausa