로컬 네트워크에서 내 가족을위한 간단한 http 서버를 만들었습니다. html 파일과 PNG 그림을 추가하고 HTML 파일을 보려고했는데 이미지를로드 할 수 없습니다.
은 말한다 :
"이미지"에 http : // 을 :... 255/header.png가 ".이 오류를 포함하고 있기 때문에 표시 할 수 없습니다"
여기 내 코드python http 웹 서버
elif self.path.endswith(".bm"): #our dynamic content
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
f= open(curdir + sep + self.path)
ren = self.render(f.read())
self.wfile.write(ren)
return
elif self.path.endswith('.png'):
print "IMAGE WANTED!"
self.send_response(200)
self.send_header('Content-type', 'image/png')
self.end_headers()
f = open(curdir + sep + self.path)
self.wfile.write(f.read())
return
elif self.path.endswith('.jpg'):
print "IMAGE WANTED!"
self.send_response(200)
self.send_header('Content-type', 'image/jpeg')
self.end_headers()
f= open(curdir + sep + self.path)
print f.read()
self.wfile.write(f.read())
return
elif self.path.endswith(".esp"):
self.send_response(200)
self.send_header('Content-type', 'text/plain')
self.end_headers()
self.wfile.write("This Format Is Not Supported Any More, Upgrade To BM Script")
return
의 비트입니다 그들은 PNG 및 JPEG 부분을 제외한 모든 작업. BM 스크립트 나 자신을 esp와 동일하게 만들었습니다.
넓은 보안 구멍이 열려 있기 때문에 인터넷에서 접근 할 수 없다는 것을 알려주세요 (../../../ etc/passwd \ 0'와 같은 상대 경로 허용) –
왜 내장 된'python -m SimpleHTTPServer'를 사용하지 마십시오. 이것은 현재 디렉토리를 제공합니다. – wim