# 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'), ] import json, sys sys.stdout.write("""/* * HTTP Document data. * Automatically generated by manifest.py */ #include "netserver.h" NetServer::HTTPDocument NetServer::httpDocumentList[] = { """) 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() sys.stdout.write("{ %s, %s, %s },\n" % (quote(path), quote(data), quote(contentType))) sys.stdout.write("};\n")