Add seasocks to aos externals for http_status and add test server.
This is stage 1 of the http_status project!
Seasocks requires a rather elaborate method of compiling the code
and including the web pages into the compiled executable as raw data,
so some of the stuff in the gyp system may not be pretty. We will fix
these problems up in later revisions as needed.
The web directory holds the rudimentary files for the web server (404
message, javascript library that we will use in later stages of
designing th web page interface, and icons. web_test holds the files for
the test webpage that can be accessed at localhost:8080 when the server
is running. Again, this directory, along with the content of
http_status.cc, is temporary and intended only to show the functionality
of the server socket.
Change-Id: I2ad1598ae200b526620b014db970e980f3c8a563
diff --git a/aos/externals/seasocks/gen_embedded.py b/aos/externals/seasocks/gen_embedded.py
new file mode 100755
index 0000000..5fc0267
--- /dev/null
+++ b/aos/externals/seasocks/gen_embedded.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+
+# This file is a modified version of the gen_embedded script included in the
+# scripts directory of seasocks (version 1.1.2). It has been modified to
+# recursively find the web files itself, which was originally done by piping
+# in the results from a "find" shell command.
+
+# The embedded files includes only those that are required for the server to run
+# (including 404 files, a default index page, favicon, etc.)
+
+import os, os.path, sys
+
+o = open('embedded.h', 'w')
+
+web = []
+for root, dirs, files in os.walk("./web", topdown=False):
+ for name in files:
+ web.append(os.path.join(root, name))
+ for name in dirs:
+ web.append(os.path.join(root, name))
+
+o.write("""
+#include "internal/Embedded.h"
+
+#include <string>
+#include <unordered_map>
+
+namespace {
+
+std::unordered_map<std::string, EmbeddedContent> embedded = {
+""")
+
+for f in web:
+ bytes = open(f, 'rb').read()
+ o.write('{"/%s", {' % os.path.basename(f))
+ o.write('"' + "".join(['\\x%02x' % ord(x) for x in bytes]) + '"')
+ o.write(',%d }},' % len(bytes))
+
+o.write("""
+};
+
+} // namespace
+
+const EmbeddedContent* findEmbeddedContent(const std::string& name) {
+ auto found = embedded.find(name);
+ if (found == embedded.end()) {
+ return NULL;
+ }
+ return &found->second;
+}
+""")
+
+o.close()