1+ -- This file provided by Facebook is for non-commercial testing and evaluation
2+ -- purposes only. Facebook reserves all rights not expressly granted.
3+ --
4+ -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5+ -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6+ -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
7+ -- FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
8+ -- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
9+ -- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
10+
111{-# LANGUAGE OverloadedStrings #-}
212
313module Main (main ) where
@@ -32,7 +42,7 @@ instance ToJSON Comment where
3242
3343main :: IO ()
3444main = scotty 3000 $ do
35-
45+
3646 middleware $ staticPolicy (noDots >-> addBase " public" )
3747 middleware logStdoutDev
3848
@@ -41,7 +51,7 @@ main = scotty 3000 $ do
4151 get " /comments.json" $ do
4252 comments <- liftIO $ readFile " comments.json"
4353 json $ fromJust $ (decode comments :: Maybe [Comment ])
44-
54+
4555 post " /comments.json" $ do
4656 comments <- liftIO $ BS. readFile " comments.json"
4757 let jsonComments = fromJust $ (decode $ fromStrict comments :: Maybe [Comment ])
@@ -50,5 +60,3 @@ main = scotty 3000 $ do
5060 let allComments = jsonComments ++ [Comment comment author]
5161 liftIO $ writeFile " comments.json" (encode allComments)
5262 json allComments
53-
54-
0 commit comments