Created
March 8, 2019 14:02
-
-
Save NickAger/f61e4137aac1d9c5e0aa22f638ca8e7f to your computer and use it in GitHub Desktop.
Haskell web server from the a local directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env stack | |
| -- stack runghc --resolver lts-12.4 --install-ghc --package wai-app-static --package warp | |
| {-# LANGUAGE OverloadedStrings #-} | |
| module Main where | |
| import Data.String | |
| import Network.Wai.Application.Static (staticApp,defaultFileServerSettings) | |
| import Network.Wai.Handler.Warp (runSettings, setPort, defaultSettings, run) | |
| import Network.HTTP.Types (status200, status404) | |
| import Network.Wai (responseLBS) | |
| -- application _ respond = respond $ | |
| -- responseLBS status200 [("Content-Type", "text/plain")] "Hello World" | |
| -- main :: IO () | |
| -- main = do | |
| -- putStrLn "listening on: http://*:8080/" | |
| -- run 8080 application | |
| main :: IO () | |
| main = do | |
| putStrLn "listening on: http://*:8080/" | |
| runSettings (setPort 8080 defaultSettings) (staticApp $ defaultFileServerSettings $ fromString ".") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment