Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Simple, crappy erlang HTTP app.

  • Loading branch information...
commit 551ecbd23aeef1bab6e821f9e3e9e277b5eb6ac3 0 parents
@lstoll authored
Showing with 47 additions and 0 deletions.
  1. +2 −0  Makefile
  2. +38 −0 hello_world.erl
  3. +6 −0 run
  4. +1 −0  www/index.html
2  Makefile
@@ -0,0 +1,2 @@
+compile:
+ erlc *.erl
38 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 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  www/index.html
@@ -0,0 +1 @@
+<html><body><h1>HELLO</h1><a href="erl/hello_world:service">some dynamic content</a></body></html>
Please sign in to comment.
Something went wrong with that request. Please try again.