Skip to content

Instantly share code, notes, and snippets.

@hajimehoshi
Created September 20, 2011 03:25
Show Gist options
  • Save hajimehoshi/1228244 to your computer and use it in GitHub Desktop.
Save hajimehoshi/1228244 to your computer and use it in GitHub Desktop.
Simple Web App in Haskell
import Blaze.ByteString.Builder (fromByteString)
import Data.CaseInsensitive (mk)
import qualified Data.ByteString.Char8 as C8
import qualified Data.ByteString.UTF8 as U8
import Network.HTTP.Types
import Network.Wai
import Network.Wai.Handler.Warp (run)
myApp :: Application
myApp _ = do
return $ ResponseBuilder status headers body
where
status = statusOK
headers = [(mk $ C8.pack "Content-Type", C8.pack "text/plain; charset=utf-8")]
body = fromByteString $ U8.fromString "Hello, 世界!"
main :: IO ()
main = run port myApp
where
port = 8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment