Browse Source

start using snap framework instead of flask :)

pull/1/head
wes 8 years ago
parent
commit
c2f9745e40
  1. 30
      riotblog.cabal
  2. 24
      src/Main.hs
  3. 7
      stack.yaml

30
riotblog.cabal

@ -0,0 +1,30 @@
Name: riotblog
Version: 0.1
Synopsis: Project Synopsis Here
Description: Project Description Here
License: AllRightsReserved
Author: Author
Maintainer: maintainer@example.com
Stability: Experimental
Category: Web
Build-type: Simple
Cabal-version: >=1.2
Executable riotblog
hs-source-dirs: src
main-is: Main.hs
Build-depends:
base >= 4 && < 5,
bytestring >= 0.9.1 && < 0.11,
monad-control >= 1.0 && < 1.1,
mtl >= 2 && < 3,
snap-core >= 1.0 && < 1.1,
snap-server >= 1.0 && < 1.1,
ginger
if impl(ghc >= 6.12.0)
ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2
-fno-warn-unused-do-bind
else
ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2

24
src/Main.hs

@ -0,0 +1,24 @@
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Applicative
import Snap.Core
import Snap.Util.FileServe
import Snap.Http.Server
main :: IO ()
main = quickHttpServe site
site :: Snap ()
site =
ifTop (writeBS "Hello, world! Hey Hey Hey") <|>
route [ ("foo", writeBS "bar")
, ("echo/:echoparam", echoHandler)
] <|>
dir "static" (serveDirectory ".")
echoHandler :: Snap ()
echoHandler = do
param <- getParam "echoparam"
maybe (writeBS "must specify echo/param in URL")
writeBS param

7
stack.yaml

@ -0,0 +1,7 @@
flags: {}
extra-package-dbs: []
packages:
- '.'
extra-deps:
- ginger-0.3.7.2
resolver: lts-7.12
Loading…
Cancel
Save