According to the above, here you want to write 
resp.append("Content-Type: %s" % mimetype)
or something similar.