0
저는 파이썬의 소켓에서 새로 왔으며 클라이언트의 POST 요청을 사용하여 이미지를 보내고 서버에 이미지를 저장해야합니다.파이썬 소켓에서 HTTP 포스트 요청으로 이미지를 받고 저장하는 방법은 무엇입니까?
클라이언트를 올바르게 준비했다고 생각하지만 확실하지 않습니다.
이 내 클라이언트 코드 :
import httplib
def printText(txt):
lines = txt.split('\n')
for line in lines:
print line.strip()
httpServ = httplib.HTTPConnection("127.0.0.1", 80)
httpServ.connect()
var = raw_input("Please enter a path of an image: ")
image = open(var, 'rb')
image_data = image.read()
image.close()
httpServ.request('POST', '/uplaod', image_data)
response = httpServ.getresponse()
if response.status == httplib.OK:
print "Output from CGI request"
printText(response.read())
httpServ.close()
내 문제는 내가 서버 측에서 해당 이미지를받을 방법 어떻게 내가 어떤 경로받을 이미지를 저장 않는다는 것입니다.