I have a simple hello world Servant application. I need to add some static or dynamic html pages to it. How can I do that? In the documentation it's not mentioned. Note I don't want to create a html layout in Haskell code, I want Haskell to show the html pages that's already created.
UPDATE:
How can I combine this:
type MyApi = "/" :> Raw
server :: Server MyApi
server = serveDirectory "static/" -- index.html, about.html
with what I have already:
type API =
"api" :> "items" :> Get '[JSON] [MyData] :<|>
"api" :> "items" :> Capture "id" Int :> Get '[JSON] MyData
app :: Application
app = serve api server
api :: Proxy API
api = Proxy
server :: Server API
server = getItems :<|> getItem
startApp :: IO ()
startApp = run 1234 app
UPDATE2:
Working:
type API =
"api" :> "items" :> Get '[JSON] [MyData] :<|>
"api" :> "items" :> Capture "id" Int :> Get '[JSON] MyData :<|>
Raw
Not working, no response at all:
type API =
"api" :> "items" :> Get '[JSON] [MyData] :<|>
"api" :> "items" :> Capture "id" Int :> Get '[JSON] MyData :<|>
"/" :> Raw
-- or
type API =
"api" :> "items" :> Get '[JSON] [MyData] :<|>
"api" :> "items" :> Capture "id" Int :> Get '[JSON] MyData :<|>
"" :> Raw
I wonder why?