Created
November 22, 2011 22:45
-
-
Save ostollmann/1387289 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
{-# OPTIONS_GHC -XTypeSynonymInstances #-} | |
{-| | |
This is where all the routes and handlers are defined for your site. The | |
'app' function is the initializer that combines everything together and | |
is exported by this module. | |
-} | |
module Site | |
( app | |
) where | |
import Control.Applicative | |
import Control.Monad.Trans | |
import Control.Monad.State | |
import Data.ByteString (ByteString) | |
import Data.ByteString.Char8 as B hiding (null,head,length) | |
import Data.Maybe | |
import Data.Either | |
import qualified Data.Text as T | |
import qualified Data.Text.Encoding as T | |
import Data.Time.Clock | |
import Snap.Core | |
import Snap.Snaplet | |
import Snap.Snaplet.Heist | |
import Snap.Util.FileServe | |
import Text.Templating.Heist | |
import Text.XmlHtml hiding (render) | |
import Text.JSON | |
import Database.SQLite | |
import qualified XGen.Base as XGen | |
import Application | |
handler = do | |
expr <- fromMaybe "" <$> getParam "expr" | |
r <- getRequest | |
writeBS (append (B.pack "expr: ") expr) | |
writeBS (append (B.pack "\n PathInfo: ") $ rqPathInfo r) | |
-- writeBS $ B.pack (generate $ B.unpack $ fromMaybe "" $ urlDecode expr) | |
routes' = [("/api/generate/:expr/", handler)] | |
-- | |
------------------------------------------------------------------------------ | |
-- | The application initializer. | |
app :: SnapletInit App App | |
app = makeSnaplet "app" "An snaplet example application." Nothing $ do | |
sTime <- liftIO getCurrentTime | |
h <- nestSnaplet "heist" heist $ heistInit "resources/templates" | |
_ <- liftIO $ Prelude.putStrLn "yyyyyyyyyyyyyyyyyyyyy" | |
addRoutes routes' | |
return $ App h sTime |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment