Last active
October 9, 2015 12:30
-
-
Save ishiy1993/319390489bba82001620 to your computer and use it in GitHub Desktop.
HaskellでWebサーバー
This file contains 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
{-# LANGUAGE OverloadedStrings #-} | |
import Data.ByteString.Char8 (unpack) | |
import Network.Wai | |
import Network.HTTP.Types (status200) | |
import Network.Wai.Handler.Warp (run) | |
application :: Application | |
application req respond = case rawPathInfo req of | |
"/" -> respond $ responseFile status200 [("Content-Type", "text/html")] "index.html" Nothing | |
p -> respond $ responseFile status200 [] p' Nothing | |
where p' = tail . unpack $ p | |
main :: IO() | |
main = do | |
putStrLn "Server started" | |
run 3000 application |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment