haskell - Minimal warp webserver example -
i want create website using warp webserver in haskell. i'm haskell beginner, examples this one complex me.
can show me simple, minimal example of how use warp?
note: question intentionally shows no research effort answered q&a-style.
here's minimal hello world application using warp 3.0+. run it, navigate http://localhost:3000
. example show hello world
.
in order keep example minimal, url paths not handled @ (the same content delivered path). longer example incorporating url path handling, see the haskell wiki
{-# language overloadedstrings #-} import network.wai (responselbs, application) import network.wai.handler.warp (run) import network.http.types (status200) import network.http.types.header (hcontenttype) main = let port = 3000 putstrln $ "listening on port " ++ show port run port app app :: application app req f = f $ responselbs status200 [(hcontenttype, "text/plain")] "hello world!"
update 2014-06-20: warp 3.0 included api changes -- reflect them in code.
Comments
Post a Comment