5 bin/start_4999 (jungerl's bin directory must also be in your PATH)
7 erl -pa ebin -s pico_test start
8 3) point your browser at http://localhost:4999/index.html
9 (N.B. unlike Apache there is no automatic redirection from a directory
12 As specified in pico_test.erl, files are served from the 'htdocs'
18 pico_http_server:start(Port, Max, Mod, [Arg1, Arg2]).
20 Creates a process called pico_port_<Port>
23 Port - listening TCP/IP port
24 Max - limits simultaneous connections
25 Mod - name of handler module (e.g. ?MODULE if in caller's module)
26 [...] - arguments to Mod:start()
28 pico_http_server:stop(Port, Reason)
33 Mod:start_handler(Arg1, Arg2) -> State
35 Mod:event_handler({get|post,Hostname,Uri,Args}, State) ->
37 { [header({ok,html}), Response], State' }
38 Return a 200 OK status, with Response as content. 'html' indicates
39 content type; 'text' and other types are also valid,
40 see pico_utils:mime().
42 or { [header({error,Code,Response})], State' }
43 Return error status, where Response is a plain text error message
44 returned to web client. Code is the HTTP status: three digit code,
45 followed by one line description
46 (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html).
48 or { [header({redirect,Loc})], State' }
49 issues a 302 temporary redirection to a new URL given by Loc.
51 Note: Hostname, Uri & Args are parsed from the GET/POST request.
53 http://localhost:8080/script/submit?name=Sally&colour=Blue
54 Host: {ok,"localhost"}
56 Args: [{"name","Sally"},{"colour","Blue"}]
58 Mod:stop_handler(Reason, State) -> {Reason,State}
63 Joe's Erlang tutorial #2 explains a similar web server design.
64 http://www.sics.se/~joe/tutorials/web_server/web_server.html
66 The Jungerl project 'wiki' is a moderately complex application built
67 on the 'pico' server (see ../wiki).