Skip to content

Instantly share code, notes, and snippets.

@dbushenko
Created April 19, 2015 08:43
Show Gist options
  • Save dbushenko/9c2c0c4df8e8c850af8a to your computer and use it in GitHub Desktop.
Save dbushenko/9c2c0c4df8e8c850af8a to your computer and use it in GitHub Desktop.
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.Default (def)
import Web.Scotty
import Data.Monoid (mconcat)
import Network.Wai.Middleware.Static
import Network.Wai.Middleware.RequestLogger (logStdoutDev)
import Network.Wai.Session (withSession, Session)
import Network.Wai.Session.Map (mapStore_)
import Data.String
import qualified Data.Vault.Lazy as Vault
import Control.Monad.IO.Class
import Control.Monad
import qualified Data.ByteString.Char8 as BS
main = do
session <- Vault.newKey
store <- mapStore_
scotty 3000 $ do
middleware $ staticPolicy (noDots >-> addBase "static")
middleware logStdoutDev
middleware $ withSession store (fromString "SESSION") def session
get "/:word" $ do
beam <- param "word"
html $ mconcat ["<h1>Scotty, ", beam, " me up!</h1>"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment