@@ -1,31 +0,0 @@
1−{-# LANGUAGE Rank2Types #-}
2−import Network.Wai
3−import Network.Wai.Enumerator
4−import qualified Network.Wai.Source as Source
5−import Network.Wai.Handler.SimpleServer
6−import qualified Data.ByteString.Char8 as B8
7−
8−main :: IO ()
9−main = putStrLn "http://localhost:3000/" >> run 3000 app
10−
11−app :: Application
12−app req = case B8.unpack $ pathInfo req of
13− "/post/" -> postResponse $ requestBody req
14− _ -> indexResponse
15−
16−indexResponse :: IO Response
17−indexResponse = return Response
18− { status = Status200
19− , responseHeaders = [(ContentType, B8.pack "text/html")]
20− , responseBody = index
21− }
22−
23−postResponse :: Source -> IO Response
24−postResponse rb = return Response
25− { status = Status200
26− , responseHeaders = [(ContentType, B8.pack "text/plain")]
27− , responseBody = Right $ fromLBS' $ Source.toLBS rb
28− }
29−
30−index :: Either FilePath a
31−index = Left "index.html"