29 lines
No EOL
767 B
Python
29 lines
No EOL
767 B
Python
def buildHeader(statusCode, mime, size):
|
|
header = (headers[str(statusCode)] + "Content-type: " + mimeTypes[mime] + "\nContent-Length: " + str(size) + "\n\n").encode("utf-8")
|
|
return header
|
|
|
|
|
|
headers = {
|
|
"200":"HTTP/1.1 200 OK\n",
|
|
"404":"HTTP/1.0 404 Not Found\n",
|
|
"500":"HTTP/1.1 500 Internal Server Error\n",
|
|
"301":"HTTP/1.1 301 Moved Permanently\n"
|
|
}
|
|
|
|
mimeTypes = {
|
|
"plain":"text/plain",
|
|
"txt":"text/plain",
|
|
"html":"text/html",
|
|
"css":"text/css",
|
|
"js":"text/javascript",
|
|
"png":"image/png",
|
|
"bmp":"image/bmp",
|
|
"gif":"image/gif",
|
|
"ico":"image/x-icon",
|
|
"jpeg":"image/jpeg",
|
|
"svg":"image/svg+xml",
|
|
"wav":"audio/wav",
|
|
"mp3":"audio/mpeg",
|
|
"zip":"application/zip",
|
|
"pdf":"application/pdf"
|
|
} |