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
+
1
11
{-# LANGUAGE OverloadedStrings #-}
2
12
3
13
module Main (main ) where
@@ -32,7 +42,7 @@ instance ToJSON Comment where
32
42
33
43
main :: IO ()
34
44
main = scotty 3000 $ do
35
-
45
+
36
46
middleware $ staticPolicy (noDots >-> addBase " public" )
37
47
middleware logStdoutDev
38
48
@@ -41,7 +51,7 @@ main = scotty 3000 $ do
41
51
get " /comments.json" $ do
42
52
comments <- liftIO $ readFile " comments.json"
43
53
json $ fromJust $ (decode comments :: Maybe [Comment ])
44
-
54
+
45
55
post " /comments.json" $ do
46
56
comments <- liftIO $ BS. readFile " comments.json"
47
57
let jsonComments = fromJust $ (decode $ fromStrict comments :: Maybe [Comment ])
@@ -50,5 +60,3 @@ main = scotty 3000 $ do
50
60
let allComments = jsonComments ++ [Comment comment author]
51
61
liftIO $ writeFile " comments.json" (encode allComments)
52
62
json allComments
53
-
54
-
0 commit comments