Splitting a mochiweb web app between two servers

9 views
Skip to first unread message

Ivan Uemlianin

unread,
Dec 21, 2009, 6:42:50 AM12/21/09
to MochiWeb
Dear All

I am learning Erlang. I am working through the new O'Reilly Erlang
Programming (I also have Programming Erlang), and I am experimenting
with the stickyNotes MochiWeb demo [refs]. My practical objective is
to be able to implement components of a dynamic website in Erlang: in
particular, a chat server. I am not against writing the whole website
in Erlang, but for now I am looking at integrating an Erlang component
into a foreign web application (eg a Django-based website).

As a first step I am experimenting with the stickyNotes demo, using
MochiWeb. Out of the box it works fine, and is a nice little demo of
how Erlang can support a web application. I should like to have the
static html (& images, js, etc) come from one server, with the Erlang
app on a different server. To simulate this I have it set up like
this:

webpage: http://localhost/~ivan/stickyNotes/index.html
erlang: http://localhost:8000

However, this doesn't work. The gist of it is that the erlang
application is expecting a POST request (loop() in stickyNotes/src/
stickyNotes_web.erl), but with the above setup it's receiving an
OPTIONS request.

I need to figure out what stickyNotes_web.erl should do with an
OPTIONS request, and how to get the browser to send POST requests.

I realise this is not an Erlang question. It's probably more to do
with the change in the http handshake caused by the split between two
servers. However, is this something MochiWeb (and/or WebMachine) can
handle? Or is this the wrong way to split the app between two
servers?

Any help appreciated. Once I've sorted it out I'll post a summary.

Best wishes

Ivan

[refs]

http://beebole.com/en/blog/erlang/tutorial-web-application-erlang/

Reply all
Reply to author
Forward
0 new messages