1 {-# LANGUAGE TemplateHaskell #-}
2 module Handler.Home where
5 import Yesod.Form.Bootstrap3 (BootstrapFormLayout (..), renderBootstrap3,
8 -- This is a handler function for the GET request method on the HomeR
9 -- resource pattern. All of your resource patterns are defined in
12 -- The majority of the code you will write in Yesod lives in these handler
13 -- functions. You can spread them across multiple files if you are so
14 -- inclined, or create a single monolithic file.
15 getHomeR :: Handler Html
17 (formWidget, formEnctype) <- generateFormPost sampleForm
18 let submission = Nothing :: Maybe (FileInfo, Text)
19 handlerName = "getHomeR" :: Text
22 setTitle "Welcome To Yesod!"
23 $(widgetFile "homepage")
25 postHomeR :: Handler Html
27 ((result, formWidget), formEnctype) <- runFormPost sampleForm
28 let handlerName = "postHomeR" :: Text
29 submission = case result of
30 FormSuccess res -> Just res
35 setTitle "Welcome To Yesod!"
36 $(widgetFile "homepage")
38 sampleForm :: Form (FileInfo, Text)
39 sampleForm = renderBootstrap3 BootstrapBasicForm $ (,)
40 <$> fileAFormReq "Choose a file"
41 <*> areq textField (withSmallInput "What's on the file?") Nothing