我正在将Python2.6应用程序转换为Python3应用程序,我被服务器卡住了。我已经设法让它服务的get请求只是罚款,但邮政继续躲避我。这是我在2.6中开始的工作,但在3.x中,普通服务器不处理POST请求。从我对Python手册的阅读来看,似乎我必须使用CGI服务器类,并且还必须将脚本映射到该目录。我宁愿不用这样做,但我找不到别的办法。我遗漏了什么吗?
def do_POST(self):
ctype, pdict = cgi.parse_header(self.headers.get('content-type'))
if ctype == 'multipart/form-data':
query = cgi.parse_multipart(self.rfile, pdict)
self.send_response(301)
self.end_headers()
upfilecontent = query.get('upfile')
print("filecontent", upfilecontent[0])
self.wfile.write("<HTML>POST OK.<BR><BR>");
self.wfile.write(upfilecontent[0]);
在戳和几个小时的谷歌搜索之后,我发现了以下的作品。
我很惊讶这么简单。
相关问题 更多 >
编程相关推荐