每当我将一个python文件上传到除main.py之外的Google App Engine时,我在尝试加载网站时出现404错误。例如,当我在yaml中包含test.py部分时,我在整个站点上收到404错误。这是我的yaml
application: pythontest
version: 1
runtime: python
api_version: 1
threadsafe: true
handlers:
- url: /(.*\.(gif|png|jpg|ico|js|css))
static_files: \1
upload: (.*\.(gif|png|jpg|ico|js|css))
- url: /python/test.py
static_files: test.py
- url: .*
script: main.py
我的main.py
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:
q = '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, {}))
def main ():
application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)
util.run_wsgi_app (application)
if __name__ == '__main__':
main ()
导致这种情况发生的原因是什么?