Skip to content

Instantly share code, notes, and snippets.

@MnO2
Created February 28, 2013 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MnO2/5058390 to your computer and use it in GitHub Desktop.
Save MnO2/5058390 to your computer and use it in GitHub Desktop.
Failed URI Hello World
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Applicative
import Snap.Core
import Snap.Util.FileServe
import Snap.Http.Server
import Data.Text (Text)
import Data.Text.Encoding(encodeUtf8)
main :: IO ()
main = quickHttpServe site
site :: Snap ()
site =
ifTop (writeBS "hello world") <|>
route [ ("foo", writeBS "bar")
, ("echo", pathArg echoHandler)
] <|>
dir "static" (serveDirectory ".")
echoHandler :: Text -> Snap ()
echoHandler name = do
writeBS $ encodeUtf8 name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment