2013-11-29 40 views
1

我是Google App Engine的新手,我試圖創建一個簡單的多頁面應用程序(index.htm,sites.htm,topics.htm)。當我運行沒有文件名的應用程序時,一切都很好http://localhost:9080。但是,當我試圖加載特定頁面http://localhost:9080/index.htmhttp://localhost:9080/sites.htmhttp://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 

任何指導,將不勝感激

回答