Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added a web hello world eample using mochiweb and simplebridge

  • Loading branch information...
commit f9f45d68afd3e10b67367625b880e6a336a93b7f 1 parent 623c279
@marianoguerra authored
Showing with 22 additions and 0 deletions.
  1. +22 −0 examples/hello.ifn
View
22 examples/hello.ifn
@@ -0,0 +1,22 @@
+# see: http://efene.tumblr.com/post/582917490/web-hello-world-with-mochiweb-and-simplebridge-in
+
+@public
+start = fn ()
+ Options = [(ip, "127.0.0.1"), (port, 8000)]
+ Loop = fn loop:1
+ mochiweb_http.start([(name, mochiweb_example_app), (loop, Loop) : Options])
+
+response = fn (Req, Root)
+ simple_bridge.make_response(mochiweb_response_bridge, (Req, Root))
+
+response_ok = fn (Req, Root, ContentType, Data)
+ Response = response(Req, Root)
+ Response1 = Response.status_code(200)
+ Response2 = Response1.header("Content-Type", ContentType)
+ Response3 = Response2.data(Data)
+ Response3.build_response()
+
+@public
+loop = fn (Req)
+ HTML = ["<h1>Hello, World!</h1>"]
+ response_ok(Req, "./wwwroot", "text/html", HTML)

0 comments on commit f9f45d6

Please sign in to comment.
Something went wrong with that request. Please try again.