【发布时间】:2015-08-31 16:38:44
【问题描述】:
我正在运行下面的代码来获取 POST 消息。如何获取文件(通过 POST 发送)以及如何使用 HTTP 状态码 200 回复 OK?
#!/usr/bin/env python
import ssl
import BaseHTTPServer, SimpleHTTPServer
from BaseHTTPServer import BaseHTTPRequestHandler
class HttpHandler(BaseHTTPRequestHandler):
def do_POST(self):
print "got POST message"
# how do I get the file here?
print self.request.FILES
httpd = BaseHTTPServer.HTTPServer(('localhost', 4443), HttpHandler)
httpd.socket = ssl.wrap_socket(httpd.socket, certfile='./server.pem', server_side=True)
httpd.serve_forever()
$curl -X POST -d @../some.file https://localhost:4443/resource --insecure
AttributeError: 'SSLSocket' 对象没有属性 'FILES'
【问题讨论】:
标签: python http post https httphandler