Google app engine MainHandler不处理所有页面请求-Google应用程序引擎
我是谷歌应用程序引擎的新手,我正在尝试创建一个简单的多页面应用程序(index.htm、sites.htm、topics.htm)。当我运行没有文件名的应用程序时,一切都很好Google app engine MainHandler不处理所有页面请求-Google应用程序引擎,google-app-engine,python-2.7,webapp2,multipage,Google App Engine,Python 2.7,Webapp2,Multipage,我是谷歌应用程序引擎的新手,我正在尝试创建一个简单的多页面应用程序(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错误 这是我的应用程序 application
http://localhost:9080
。但是当我试图加载一个特定的页面http://localhost:9080/index.htm
或http://localhost:9080/sites.htm
或http://localhost:9080/topics.htm
,我收到404错误
这是我的应用程序
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"
我的主处理器如下
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)
非常感谢您提供任何指导您必须创建路线:
('/',MainHandler)
将仅处理:/
要处理所有请求,请使用:
app = webapp2.WSGIApplication(
[
('/.*', MainHandler),
], debug=True)
您必须创建路由:
('/',MainHandler)
将仅处理:/
要处理所有请求,请使用:
app = webapp2.WSGIApplication(
[
('/.*', MainHandler),
], debug=True)
我可以创建泛型路由来处理单个处理程序中的*.htm之类的事情吗?我可以创建泛型路由来处理单个处理程序中的*.htm之类的事情吗?