我有以下的app.yaml文件。
我应该部署的文件只是 html 文件、js 或者图片,编译应用程序后我遇到了以下错误:
application: gtryapp
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /images/(.*\.(gif|png|jpg))
static_files: static/img/\1
upload: static/img/(.*\.(gif|png|jpg))
- url: /css/(.*\.css)
mime_type: text/css
static_files: static/css/\1
upload: static/css/(.*\.css)
- url: /js/(.*\.js)
mime_type: text/javascript
static_files: static/js/\1
upload: static/js/(.*\.js)
- url: /(.*\.html)
mime_type: text/html
static_files: static/\1
upload: static/(.*\.html)
- url: .*
script: main.app
libraries:
- name: webapp2
version: "2.5.2"
而文件app.py:
import webapp2
class MainPage(webapp2.RequestHandler):
def get(self):
if self.request.url.endswith('/'):
path = '%sindex.html'%self.request.url
else:
path = '%s/index.html'%self.request.url
self.redirect(path)
application = webapp2.WSGIApplication([('/.*', MainPage)],
debug=True)
我应该部署的文件只是 html 文件、js 或者图片,编译应用程序后我遇到了以下错误:
raise ImportError('%s 没有属性 %s' % (handler, name)) ImportError: 没有 app 属性
解决方案:我需要调用 "app" 而不是 "application"!
app = webapp2.WSGIApplication([('/.*', MainPage)],
debug=True)
self.redirect(path)
application = webapp.WSGIApplication([('/.*', IndexHandler)], debug=True)但仍然无法正常工作。 - FrankTan