Skip to content

Instantly share code, notes, and snippets.

@ishiy1993
Last active October 9, 2015 12:30
Show Gist options
  • Save ishiy1993/319390489bba82001620 to your computer and use it in GitHub Desktop.
Save ishiy1993/319390489bba82001620 to your computer and use it in GitHub Desktop.
HaskellでWebサーバー
{-# 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