我正在尝试从 python 迁移到 2.7 到 2.5,但是在对 main.py 和 app.yaml 文件进行了必要的更改后,我的网站无法运行
请帮助...我应该对这些进行哪些更改才能使其正常工作
主文件
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 ()
应用程序.yaml
application: cool-gadgets
version: 1
runtime: python
api_version: 1
handlers:
- url: /robots.txt
static_files: static/robots.txt
upload: static/robots.txt
- url: /favicon.ico
static_files: static/favicon.ico
upload: static/favicon.ico
- url: /gadgets/disney.xml
static_files: gadgets/disney.xml
upload: gadgets/disney.xml
- url: /gadgets/wwe.xml
static_files: gadgets/wwe.xml
upload: gadgets/wwe.xml
- url: .*
script: main.py
我对此进行的更改以迁移到 2.7
主文件
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, {}))
application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)
应用程序.yaml
application: cool-gadgets
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /robots.txt
static_files: static/robots.txt
upload: static/robots.txt
- url: /favicon.ico
static_files: static/favicon.ico
upload: static/favicon.ico
- url: /gadgets/disney.xml
static_files: gadgets/disney.xml
upload: gadgets/disney.xml
- url: /gadgets/wwe.xml
static_files: gadgets/wwe.xml
upload: gadgets/wwe.xml
- url: .*
script: main.application