Created
February 26, 2018 15:22
-
-
Save BlakeRain/9ce990e5dbb1546f245a92a4bef50a08 to your computer and use it in GitHub Desktop.
Example Empty Post
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 TypeFamilies, OverloadedStrings, TemplateHaskell, QuasiQuotes #-} | |
import qualified Network.Wai.Handler.Warp as Warp | |
import qualified Network.Wai.Handler.WarpTLS as WarpTLS | |
import Yesod.Core | |
data SimpleApp = | |
SimpleApp | |
mkYesod "SimpleApp" [parseRoutes| | |
/ RootR GET POST | |
|] | |
instance Yesod SimpleApp | |
getRootR :: Handler Html | |
getRootR = defaultLayout $ do | |
setTitle "Empty Form" | |
[whamlet| | |
<form method=POST action=@{RootR}> | |
<p> | |
This is an empty form | |
<button type=submit> | |
Submit Form | |
|] | |
postRootR :: Handler () | |
postRootR = | |
redirect RootR | |
main :: IO () | |
main = do | |
app <- toWaiApp SimpleApp | |
WarpTLS.runTLS tls_settings warp_settings app | |
where | |
tls_settings = | |
WarpTLS.tlsSettings "test-certificate.pem" "test-key.pem" | |
warp_settings = | |
Warp.setPort 4000 $ Warp.defaultSettings | |
-- Warp.setHTTP2Disabled $ Warp.setPort 4000 $ Warp.defaultSettings |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment