Skip to content

Commit

Permalink
CGI example in router module
Browse files Browse the repository at this point in the history
  • Loading branch information
jhs committed Dec 6, 2010
1 parent 1c5b279 commit a93118e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions 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>"
3 changes: 3 additions & 0 deletions example/src/webdirs.erl
Expand Up @@ -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
Expand Down

0 comments on commit a93118e

Please sign in to comment.