Commit a7d00ce7 authored by Nicolas Lenz's avatar Nicolas Lenz
Browse files

Initial commit

parents
dist*
static/tmp/
static/combined/
config/client_session_key.aes
*.hi
*.o
*.sqlite3
*.sqlite3-shm
*.sqlite3-wal
.hsenv*
cabal-dev/
.stack-work/
.stack-work-devel/
yesod-devel/
.cabal-sandbox
cabal.sandbox.config
.DS_Store
*.swp
*.keter
*~
\#*
surver.cabal
# Surver
Tiny survey server made for use as backend of HTML form-based surveys and quizzes.
import Application () -- for YesodDispatch instance
import Foundation
import Yesod.Core
main :: IO ()
main = warp 3000 App
admin:
user: Eisfunke
password-hash: abc123abc123
forms:
- id: fupro-wise
type: survey
success:
redirect: https://example.com
questions:
- id: name
type: string
- id: age
type: int
- id: rating
type: string
- id: geocache-123
type: quiz
success:
file: winner.html
fail:
file: loser.html
questions:
- id: coord1
type: string
solution: Sphinx
- id: coord2
type: string
solution: Fernsehturm
/ HomeR GET
/add/#Int/#Int AddR GET
cradle:
stack:
name: surver
version: "0.0.0"
dependencies:
- base
- yesod-core
library:
source-dirs: src
executables:
surver:
main: Main.hs
source-dirs: app
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- surver
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
module Add where
import Foundation
import Yesod.Core
getAddR :: Int -> Int -> Handler TypedContent
getAddR x y = selectRep $ do
provideRep $ defaultLayout $ do
setTitle "Addition"
[whamlet|#{x} + #{y} = #{z}|]
provideJson $ object ["result" .= z]
where
z = x + y
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Application where
import Foundation
import Yesod.Core
import Add
import Home
mkYesodDispatch "App" resourcesApp
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ViewPatterns #-}
module Foundation where
import Yesod.Core
data App = App
mkYesodData "App" $(parseRoutesFile "config/routes.yesodroutes")
instance Yesod App where
-- we don't need a session backend as we don't have sessions
makeSessionBackend _ = pure Nothing
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
module Home where
import Foundation
import Yesod.Core
getHomeR :: Handler Html
getHomeR = defaultLayout $ do
setTitle "Minimal Multifile"
[whamlet|
<p>
<a href=@{AddR 5 7}>HTML addition
<p>
<a href=@{AddR 5 7}?_accept=application/json>JSON addition
|]
resolver: lts-17.2
# This file was autogenerated by Stack.
# You should not edit this file by hand.
# For more information, please see the documentation at:
# https://docs.haskellstack.org/en/stable/lock_files
packages: []
snapshots:
- completed:
size: 563099
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/17/2.yaml
sha256: 92b1a17e31d0a978fca4bf270305d4d1dd8092271bf60eafbc9349c890854026
original: lts-17.2
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment