同样,这里的n00b :使用以下代码尝试Warp和WAI,如文档中所示。
{-# LANGUAGE OverloadedStrings, DeriveGeneric #-}
import Network.Wai
import Network.HTTP.Types
import Network.Wai.Handler.Warp (run)
app3 :: Application
app3 request respond = respond $ case rawPathInfo request of
"/" -> index
"/raw/" -> plainIndex
_ -> notFound
plainIndex :: Response
plainIndex = responseFile
status200
[("Content-Type", "text/plain")]
"index.html"
Nothing
notFound :: Response
notFound = responseLBS
status404
[("Content-Type", "text/plain")]
"404 - Not Found"在plainIndex中运行GHCi返回:
<interactive>:12:1: error:
• No instance for (Show Response) arising from a use of ‘print’
• In a stmt of an interactive GHCi command: print it
*Main> :r
[1 of 1] Compiling Main ( WAI.hs, interpreted )一个问题中有两个问题:你能帮我解决这个问题吗?我是唯一一个经常遇到这样的问题的人。
https://stackoverflow.com/questions/53612336
复制相似问题