我有一个聚合物应用程序,我正在部署到Google App Engine。它是the beginner polymer tutorial的第2步。我一直在为某些资源获取404和500错误,特别是这些错误:
GET http://polymer-test-nik.appspot.com/images/avatar-07.svg 404 (Not Found) polymer-test-nik.appspot.com/:66
GET http://polymer-test-nik.appspot.com/components/core-header-panel/core-header-panel.html 500 (Internal Server Error) polymer-test-nik.appspot.com/:10
GET http://polymer-test-nik.appspot.com/images/avatar-07.svg 404 (Not Found) polymer-test-nik.appspot.com/:66
GET http://polymer-test-nik.appspot.com/components/core-selector/core-selector.html 500 (Internal Server Error) polymer-test-nik.appspot.com/:78
目录结构与教程相同。
我使用简单的main.py来提供应用
import random
import os
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext.webapp import template
class MainHandler(webapp.RequestHandler):
def get (self, q):
if q is None:
i = random.randint(1,11)
q = 'step-2/index.html'
path = os.path.join (os.path.dirname (__file__), q)
self.response.headers ['Content-Type'] = 'text/html'
self.response.out.write (template.render (path, {}))
class GuideHandler(webapp.RequestHandler):
def get (self, q):
q = 'icgt-registration-guide.pdf'
path = os.path.join (os.path.dirname (__file__), q)
self.response.headers ['Content-Type'] = 'application/pdf'
self.response.out.write (template.render (path, {}))
def main ():
application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)
util.run_wsgi_app (application)
if __name__ == '__main__':
main ()
答案 0 :(得分:0)
将以下内容添加到app.yaml
:
handlers:
- url: /components
static_dir: components
- url: /images
static_dir: images
值得注意的是,这些处理程序应该在 url: .*
声明之后添加,否则它将捕获所有并且永远不会进一步下降,所以在这个简单的示例中,完整声明将如下所示:
handlers:
- url: /components
static_dir: components
- url: /images
static_dir: images
- url: .*
script: main.py
我还建议您使用webapp2 framework代替它,建议新的应用程序以及更好的方式!