Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google app engine MainHandler不处理所有页面请求-Google应用程序引擎_Google App Engine_Python 2.7_Webapp2_Multipage - Fatal编程技术网

Google app engine MainHandler不处理所有页面请求-Google应用程序引擎

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

我是谷歌应用程序引擎的新手,我正在尝试创建一个简单的多页面应用程序(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: 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之类的事情吗?