This commit is contained in:
2020-11-08 12:30:48 +08:00
parent c028f79644
commit eed6556de7
3 changed files with 31 additions and 1 deletions

View File

@@ -4,6 +4,11 @@ Haskell Language Tests
```shell
$ stack helloworld.hs
```
New project:
```shell
$ stack new sample

20
explore.hs Normal file
View File

@@ -0,0 +1,20 @@
#!/usr/bin/env stack
{- stack script
--resolver nightly-2019-12-22
--install-ghc
--package "servant-server warp"
--ghc-options -Wall
-}
{-# LANGUAGE DataKinds, TypeOperators, TypeApplications #-}
module FileServer where
import Network.Wai.Handler.Warp( defaultSettings, runSettings, setBeforeMainLoop, setPort)
import Servant (Proxy(Proxy), Raw, serve, serveDirectoryWebApp)
main :: IO ()
main = runSettings settings . serve (Proxy @Raw) $ serveDirectoryWebApp "."
where port = 8080
msg = "serving on http://localhost:" ++ show port ++ "/{pathToFile}"
settings = setPort port $ setBeforeMainLoop (putStrLn msg) defaultSettings

5
helloworld.hs Normal file
View File

@@ -0,0 +1,5 @@
{- stack script
--resolver lts-14.18
-}
main :: IO ()
main = putStrLn "Hello World!"