Dynamicly generated websites in Erlang
Tue Mar 27 08:57:28 CEST 2001
> I've been told that I could use some of the code in bluetail's ticket
> tracker, but from a quick look at it I think I'd much rather use other
> (easier hopefully) options, if there are any.
Don't let the amount of code scare you. It is rather easy
to get going with INETS. Just copy the example server root
directory from the standard Erlang/OTP application, e.g:
cp -R /usr/local/usr_lib/erlang/lib/inets-2.5.3/examples/server_root xxx
Modify the xxx/conf/httpd.conf file.
Especially the directive where you state your Erlang module to be called:
ErlScriptAlias /my my
Create a file: xxx/inets.config which points out the conf file above:
cat > xxx/inets.config
Start Erlang with the switches: -config /...../xxx/inets -s my
In your startup code in my.erl, call: application:start(inets)
Now when you point a Web browser towards:
The function: my:test/2 should be called by INETS,
and whatever it returns is sent back to the web browser.
InData = httpd:parse_query(Input),
io:format("GOT THIS: ~p~n",[InData]),
%% Returning this
"<TITLE> A Test Page </TITLE>",
"<H1> A TEST </H1>",
For creating HTML content, the faqoff/html_lib.erl
module in the BTT package can be useful.
Good luck ! /Tobbe
Torbjörn Törnkvist , tel: +46 8 545 55 023 , fax: +46 8 654 70 71
Alteon Web Systems , St.Eriksgatan 44 , SE-112 34 Stockholm , Sweden
Email: , Web: http://www.alteon.com
More information about the erlang-questions