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