[erlang-questions] How to use CSS with mochiweb?

Pascal Chapier pascalchapier@REDACTED
Wed Nov 3 17:25:39 CET 2010

Well Alessandro,

I must have done something very weird. I have no html files and no place where to put them.
I buid them "on the fly", when I receive the request, depending on the fields values in each request.

I launch mochiweb with the following code (found in some forgotten forum):

init([Port]) ->
  mochiweb_http:start([{port, Port},
                {loop, fun(Req) -> dispatch(Req) end}]),
  {ok, []}.

and I decode the requests (get or post) in the dispatch function and its helpers, for example:

answer("/test", Req) ->
    Req:respond({200, [{"Content-Type", "text/html"}], page_build:test()});

:o)  While I write this I found my mistake: if i am requested a css file the content-type is text/css.

In the mean time I tried different places where to put priv/www, but none of them works, I guess that this come from the init function... 


More information about the erlang-questions mailing list