以下代码生成CGI方法而不是WSGI,如下面的日志所示。这是开发服务器上WSGI应用程序的正常执行吗?如果不是需要更改以使应用程序以WSGI的形式执行?
main.py
import webapp2
import wsgiref.handlers
import logging
from google.appengine.api import users
class HomeHandler(webapp2.RequestHandler):
def get(self):
self.response.out.write("Hi World")
app = webapp2.WSGIApplication([
(r'/', HomeHandler),
], debug=True)
app.run()
的app.yaml
application: WSGITEST
version: 1
runtime: python27
api_version: 1
threadsafe: yes
libraries:
- name: webapp2
version: latest
handlers:
- url: /.*
script: main.app
日志
DEBUG 2012-05-09 21:31:14,921 dev_appserver.py:656] Matched "/" to CGI dispatcher with path main.app
DEBUG 2012-05-09 21:31:14,926 dev_appserver_import_hook.py:1246] Enabling webapp2: None
DEBUG 2012-05-09 21:31:14,928 dev_appserver.py:1624] Executing CGI with env:
{'REQUEST_ID_HASH': '77DE68DA', 'SERVER_SOFTWARE': 'Development/1.0', 'SCRIPT_NAME': '', 'REQUEST_METHOD': 'GET', 'PATH_INFO': '/', 'SERVER_PROTOCOL': 'HTTP/1.0', 'QUERY_STRING': '', 'CONTENT_LENGTH': '', 'USER_ID': '', 'APPENGINE_RUNTIME': 'python27', 'TZ': 'UTC', 'SERVER_NAME': 'localhost', 'REMOTE_ADDR': '127.0.0.1', 'SDK_VERSION': '1.6.5', 'PATH_TRANSLATED': '/home/bear/dev/appengine/code/ae-baseapp/401/main3.app', 'SERVER_PORT': '8080', '_AH_THREADSAFE': '1', 'CURRENT_VERSION_ID': '1.1', 'USER_ORGANIZATION': '', 'HTTP_USER_AGENT': 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:12.0) Gecko/20100101 Firefox/12.0', 'HTTP_HOST': 'localhost:8080', 'HTTP_CONNECTION': 'keep-alive', 'USER_EMAIL': '', 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'APPLICATION_ID': 'dev~WSGITEST', 'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_ACCEPT_LANGUAGE': 'en-us,en;q=0.5', 'HTTP_DNT': '1', 'CONTENT_TYPE': 'application/x-www-form-urlencoded', '_AH_ENCODED_SCRIPT_NAME': '/', 'AUTH_DOMAIN': 'gmail.com'}
INFO 2012-05-09 21:31:14,933 dev_appserver.py:2891] "GET / HTTP/1.1" 200 -
答案 0 :(得分:3)
此日志是一个硬编码字符串:
/usr/local/google_appengine/google/appengine/tools/dev_appserver.py:
1622 sys.modules['__builtin__'] = __builtin__
1623
1624: logging.debug('Executing CGI with env:\n%s', repr(env))
答案 1 :(得分:1)