Newer
Older
# Manifest of files to include in the simple HTTP server.
# Run this script to generate the httpdocs.cpp source file.
manifest = [
('/', 'index.html', 'text/html'),
# 404 error document must be last.
(None, '404.html', 'text/html'),
]
print """/*
* HTTP Document data.
* Automatically generated by manifest.py
*/
#include "netserver.h"
NetServer::HTTPDocument NetServer::httpDocumentList[] = {"""
import json
def quote(str):
if str is None:
return 'NULL'
return json.dumps(str)
for path, filename, contentType in manifest:
if contentType.startswith('text/'):
mode = 'r'
else:
mode = 'rb'
data = open(filename, mode).read()
print "{ %s, %s, %s }," % (quote(path), quote(data), quote(contentType))
print "};"