-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfinalProject.hs
67 lines (57 loc) · 1.42 KB
/
finalProject.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
{-
Samantha Kacir
CS380 Final Project
Basic server implementation
-}
{-# LANGUAGE DataKinds, DeriveGeneric, FlexibleInstances, GADTs,
GeneralizedNewtypeDeriving, MultiParamTypeClasses,
OverloadedStrings, ScopedTypeVariables, TypeOperators #-}
module Server where
import Prelude ()
import Prelude.Compat
import Models
import UserApi
import Control.Monad.Except
import Control.Monad.Reader
import Data.Aeson.Compat
import Data.Aeson.Types
import Data.Attoparsec.ByteString
import Data.ByteString (ByteString)
import Data.List
import Data.Maybe
import Data.String.Conversions
import Data.Time.Calendar
import GHC.Generics
import Lucid
import Network.HTTP.Media ((//), (/:))
import Network.Wai
import Network.Wai.Handler.Warp
import Servant
import System.Directory
import System.IO
import Text.Blaze
import Text.Blaze.Html.Renderer.Utf8
import qualified Data.Aeson.Parser
import qualified Text.Blaze.Html
server1 :: Server UserAPI1
server1 =
getUsers :<|>
getUserById :<|>
getGroupsByUser :<|>
getGroupByMember :<|>
getContactsByMember
userAPI :: Proxy UserAPI1
userAPI = Proxy
-- 'serve' comes from servant and hands you a WAI Application,
-- which you can think of as an "abstract" web application,
-- not yet a webserver.
app1 :: Servant.Application
app1 = serve userAPI server1
port :: Int
port = 8080
main :: IO ()
main = do
putStr "Listening on Port "
putStr (show port)
hFlush stdout
run port app1