每当我将 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 ()
什么会导致这种情况发生?