我之前尝试过通过更改来更新我的应用程序
运行时:python27,线程安全:true,脚本:main.app"
它确实有效并且在 python 2.7 上运行,但我猜它没有正常运行,因为当我访问 URL http://dhsenviro.appspot.com时我的 index.html 没有显示。它现在在 2.5 上运行(因为我想保持它)。robots.txt 为空。如何将其更新到 2.7 还是应该将其更新到 3.x?
应用程序.yaml:
application: dhsenviro
version: 1
runtime: python
api_version: 1
handlers:
- url: /(.*\.(gif|png|jpg|ico|js|css|psd|swf))
static_files: \1
upload: (.*\.(gif|png|jpg|ico|js|css|psd|swf))
- url: /robots.txt
static_files: robots.txt
upload: robots.txt
- url: /.*
script: main.py
主.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 ()
我不想上传我的 index.html,但我确信它工作正常。
编辑:
主.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, {}))
class application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)
def main ():
if __name__ == '__main__':
main ()
正确的 APP.YAML :
application: dhsenviro
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /(.*\.(gif|png|jpg|ico|js|css|psd|swf))
static_files: \1
upload: (.*\.(gif|png|jpg|ico|js|css|psd|swf))
- url: /robots.txt
static_files: robots.txt
upload: robots.txt
- 网址:/.* 脚本:main.application
正确的 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, {}))
application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)