【发布时间】:2016-06-07 01:11:33
【问题描述】:
我正在尝试使用 Python 3.4.3 和 Bottle 0.12.8 使用 cgi 运行一个简单的 Web 服务。我正在从我的 Linux 系统运行以下脚本。我能够在没有 CGI 的情况下运行相同的服务。
======================================
import bottle
from bottle import route, run, request, response
host = 'XXXX'
port = '8080'
debug = 'False'
@route('/hello/', method=['OPTIONS','GET'])
def hello():
return("Success")
bottle.run(host=host, port=port,debug=debug,server='cgi')
#bottle.run(host=host, port=port,debug=debug)
======================================
当我使用 CGI 运行服务时出现以下错误-
Traceback (most recent call last):
File "/usr/local/lib/python3.4/site-packages/bottle.py", line 858, in _handle
route, args = self.router.match(environ)
File "/usr/local/lib/python3.4/site-packages/bottle.py", line 413, in match
verb = environ['REQUEST_METHOD'].upper()
KeyError: 'REQUEST_METHOD'
<h1>Critical error while processing request: </h1><h2>Error:</h2>
<pre>
KeyError('REQUEST_METHOD',)
</pre>
<h2>Traceback:</h2>
<pre>
Traceback (most recent call last):
File "/usr/local/lib/python3.4/site-packages/bottle.py", line 957, in wsgi
or environ['REQUEST_METHOD'] == 'HEAD':
KeyError: 'REQUEST_METHOD'
</pre>
Status: 500 INTERNAL SERVER ERROR
Content-Type: text/html; charset=UTF-8
Content-Length: 374
<h1>Critical error while processing request: </h1><h2>Error:</h2>
<pre>
KeyError('REQUEST_METHOD',)
</pre>
<h2>Traceback:</h2>
<pre>
Traceback (most recent call last):
File "/usr/local/lib/python3.4/site-packages/bottle.py", line 957, in wsgi
or environ['REQUEST_METHOD'] == 'HEAD':
KeyError: 'REQUEST_METHOD'
</pre>
Any pointers would help. Thanks
【问题讨论】: