Skip to content

Instantly share code, notes, and snippets.

@NickAger
Created March 8, 2019 14:01
Show Gist options
  • Select an option

  • Save NickAger/7692dfd746e4b381fe738f9fffb60392 to your computer and use it in GitHub Desktop.

Select an option

Save NickAger/7692dfd746e4b381fe738f9fffb60392 to your computer and use it in GitHub Desktop.
Haskell scotty example
#!/usr/bin/env stack
-- stack runghc --resolver lts-12.4 --install-ghc --package scotty --package wai --package warp --package wai-middleware-static
{-# LANGUAGE OverloadedStrings #-}
module Main where
-- import Web.Scotty
-- import qualified Text.Blaze.Html5 as H
-- import Text.Blaze.Html5 (toHtml, Html)
-- import Text.Blaze.Html.Renderer.Text (renderHtml)
-- greet :: String -> Html
-- greet user = H.html $ do
-- H.head $
-- H.title "Welcome!"
-- H.body $ do
-- H.h1 "Greetings!"
-- H.p ("Hello " >> toHtml user >> "!")
-- app = do
-- get "/" $
-- text "Home Page"
-- get "/greet/:name" $ do
-- name <- param "name"
-- html $ renderHtml (greet name)
-- main :: IO ()
-- main = scotty 8000 app
import Web.Scotty
import Data.Monoid (mconcat)
import Network.Wai.Middleware.Static
import Data.String
app = do
get "/manifest.plist" $ do
html $ mconcat ["<h1>Will process <code>manifest.plist</code></h1>"]
middleware $ staticPolicy (noDots >-> addBase ".")
-- middleware $ defaultFileServerSettings $ fromString "."
main = scotty 8080 app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment