diff --git a/espify.sh b/espify.sh
new file mode 100755
index 0000000..c67ab52
--- /dev/null
+++ b/espify.sh
@@ -0,0 +1,74 @@
+#!/bin/bash
+
+print_usage()
+{
+ echo "Usage: ./espify.sh
[]"
+ echo "Example: ./espify.sh /home/user/mywebsite"
+ echo "Example: ./espify.sh dist/ -not -name foo.html"
+}
+
+get_var_name()
+{
+ echo -e "static_$(echo -e $1 | tr -d '_' | tr '/.~-' '_')"
+}
+
+if [ "$1" == "" ]; then
+ echo "Error: missing content path." >&2
+ print_usage >&2
+ exit 1
+fi
+
+if ! [ -d "$1" ]; then
+ echo "Error: \`$1' is not a directory." >&2
+ print_usage >&2
+ exit 2
+fi
+
+prefix="$(echo $1 | sed -e 's/\/*$//')"
+prefix_len=${#prefix}
+shift 1 # Eat first argument
+
+flist="$(find -L $prefix -type f \( -name '*.js' -or -name '*.html' -or -name '*.css' -or -name 'favicon.ico' \) $@ | cut -c $[prefix_len+2]-)"
+
+cat <
+
+EOF
+
+for i in $flist; do
+ echo -e "unsigned char PROGMEM $(get_var_name $i)[] = {"
+ gzip -c "$prefix/$i" | xxd -i -c 16
+ echo -e "};\n"
+done
+
+cat <sendHeader("Content-Encoding", "gzip"); \\
+ _server->send_P(200, "text/html", (const char*)p, sizeof(p)); \\
+}
+
+static void redirect_index(void)
+{
+ _server->sendHeader("Location", "/");
+ _server->send(301);
+}
+
+EOF
+
+for i in $flist; do
+ echo -e "SERVE_STATIC($(get_var_name $i))"
+done
+
+echo -e "\nvoid gadgety_static_init_server(ESP8266WebServer* server)\n{"
+echo -e " _server = server;"
+echo -e " server->onNotFound(redirect_index);"
+echo -e " server->on(\"/\", serve_static_index_html);"
+
+for i in $flist; do
+ echo -e " server->on(\"/$i\", serve_$(get_var_name $i));"
+done
+
+echo -e "}"