Revisión 35
Añadido por Manu Mora Gordillo hace más de 14 años
autoclone/trunk/Server/WebServer.py | ||
---|---|---|
from BaseHTTPServer import BaseHTTPRequestHandler
|
||
import os
|
||
import shutil
|
||
import MyUtils
|
||
|
||
class MyHandler(BaseHTTPRequestHandler):
|
||
|
||
def do_GET(self):
|
||
try:
|
||
if self.path.endswith(".iso") or self.path.endswith(".md5"):
|
||
def do_GET(self):
|
||
try:
|
||
if self.path.endswith(".iso") or self.path.endswith(".md5"):
|
||
file = "/var/lib/autoclone/www/" + self.path
|
||
f = open(file)
|
||
s = os.path.getsize(file)
|
||
|
||
self.send_response(200)
|
||
self.send_header('Content-type', 'application/x-iso9660-image')
|
||
self.send_header('Content-type', MyUtils.getMimeType(self.path))
|
||
self.send_header('Content-Length', s)
|
||
self.end_headers()
|
||
|
||
... | ... | |
f.close()
|
||
return
|
||
|
||
except IOError:
|
||
pass
|
||
except IOError:
|
||
pass
|
autoclone/trunk/Server/MyUtils.py | ||
---|---|---|
def getFileName(file):
|
||
basename = os.path.basename(file)
|
||
filename = os.path.splitext(basename)
|
||
return filename[0]
|
||
return filename[0]
|
||
|
||
|
||
def getMimeType(path):
|
||
if path.endswith(".iso"):
|
||
return "application/x-iso9660-image"
|
||
elif path.endswith(".md5"):
|
||
return "text/plain"
|
Exportar a: Unified diff
Ya descarga también el md5