From: Adam C. <cim...@gm...> - 2008-01-19 01:18:47
|
Hello, I need to read a file, processing it and then spitting the output back to the browser. Something of the sort: <erl> out(_Context) -> process("/var/www/default/somefile.txt"). </erl> Right now my Erlang code does it by hardcoding the path, which I am not too proud of. I have noticed that there is a mappath function in yaws_server. The function however has a 3-arity rather than a 1-arity. process(yaws_server:mappath(???,???,"somefile.txt")) What are the additional arguments for and where can I get them from? |
From: Claes W. <kl...@ta...> - 2008-01-19 12:48:24
|
Adam Cimarosti wrote: > Hello, > > I need to read a file, processing it and then spitting the output > back to the browser. > > Something of the sort: > <erl> > out(_Context) -> process("/var/www/default/somefile.txt"). > </erl> > > Right now my Erlang code does it by hardcoding the path, which I am You can put the file relative to the docroot and then access the file as: file:open(A#arg.docroot ++ "/somefile.txt",[read]) /klacke |