Skip to content

Instantly share code, notes, and snippets.

@xdcrafts
Created August 8, 2013 06:15
Show Gist options
  • Save xdcrafts/6181912 to your computer and use it in GitHub Desktop.
Save xdcrafts/6181912 to your computer and use it in GitHub Desktop.
Simple example of Warp WAI usage.
{-# 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