Skip to content

Commit

Permalink
Simple, crappy erlang HTTP app.
Browse files Browse the repository at this point in the history
  • Loading branch information
lstoll committed Jun 15, 2011
0 parents commit 551ecbd
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Makefile
@@ -0,0 +1,2 @@
compile:
erlc *.erl
38 changes: 38 additions & 0 deletions hello_world.erl
@@ -0,0 +1,38 @@
-module(hello_world).
-export([start/0,service/3]).

start() ->
inets:start(httpd, [
{modules, [
mod_alias,
mod_auth,
mod_esi,
mod_actions,
mod_cgi,
mod_dir,
mod_get,
mod_head,
mod_log,
mod_disk_log
]},
{port,element(1,string:to_integer(os:getenv("PORT")))},
{server_name,"hello_world"},
{server_root,"log"},
{document_root,"www"},
{directory_index,["index.html"]},
{erl_script_alias, {"/erl", [hello_world]}},
{error_log, "error.log"},
{security_log, "security.log"},
{transfer_log, "transfer.log"},
{mime_types,[
{"html","text/html"},
{"css","text/css"},
{"js","application/x-javascript"}
]}
]).

service(SessionID, _Env, _Input) ->
mod_esi:deliver(SessionID, [
"Content-Type: text/html\r\n\r\n",
"<html><body><h1>I am dynamically generated using erlang<body></html>"
]).
6 changes: 6 additions & 0 deletions run
@@ -0,0 +1,6 @@
#! /usr/bin/env escript
main(_) ->
% c(hello_world), % Only works in REPL.
inets:start(),
hello_world:start(),
timer:sleep(100000).
1 change: 1 addition & 0 deletions www/index.html
@@ -0,0 +1 @@
<html><body><h1>HELLO</h1><a href="erl/hello_world:service">some dynamic content</a></body></html>

0 comments on commit 551ecbd

Please sign in to comment.