Created
August 8, 2013 06:15
-
-
Save xdcrafts/6181912 to your computer and use it in GitHub Desktop.
Simple example of Warp WAI usage.
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 #-} | |
module Main where | |
import Data.ByteString.Lazy.Char8 hiding (putStrLn) | |
import Network.HTTP.Types.Status | |
import Network.Wai | |
import Network.Wai.Handler.Warp (run) | |
import System.IO | |
import System.Exit | |
import Control.Concurrent | |
app :: Application | |
app _ = return $ responseLBS status200 [("Content-Type", "text/html")] "<h1>Hello from Warp!</h1>" | |
warp :: IO () | |
warp = run 8080 app | |
main :: IO () | |
main = do | |
putStrLn "http://localhost:8080" | |
forkIO warp | |
putStrLn "[ Press Enter for shutdown ]" | |
exitOnInput | |
exitOnInput = do | |
hSetBuffering stdin NoBuffering | |
_ <- getChar | |
exitSuccess |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment