Permalink
Browse files

CGI example in router module

  • Loading branch information...
1 parent 1c5b279 commit a93118eec1a65a83ba440124744c990e191d9f1d @jhs jhs committed Dec 6, 2010
Showing with 12 additions and 0 deletions.
  1. +9 −0 example/cgi.sh
  2. +3 −0 example/src/webdirs.erl
View
9 example/cgi.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+echo "Content-Type: text/html"
+echo ""
+
+echo "<html>"
+echo "<head><title>Very simple CGI</title></head>"
+echo "<body>This process $$ serving '$REQUEST_METHOD $PATH_TRANSLATED'</body>"
+echo "</html>"
View
3 example/src/webdirs.erl
@@ -95,6 +95,9 @@ route_request(Request)
?INFO("Reloading plugin", []),
_Pid = spawn(fun() -> reload() end),
{reply, {200, "Reloading"}, [{'Content-Type', <<"text/html">>}], <<"Policy reloaded. <a href='/'>Try now.</a>\r\n">>}
+ ; "cgi-bin"
+ -> ?INFO("Executing CGI", [])
+ , {cgi, "cgi.sh"} % Absolute path, otherwise this runs from the CWD. The README says to run it from "example".
; _ ->
Dirs = string:tokens(Path, "/"),
case Dirs of

0 comments on commit a93118e

Please sign in to comment.