Created
September 20, 2011 03:25
-
-
Save hajimehoshi/1228244 to your computer and use it in GitHub Desktop.
Simple Web App in Haskell
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
import Blaze.ByteString.Builder (fromByteString) | |
import Data.CaseInsensitive (mk) | |
import qualified Data.ByteString.Char8 as C8 | |
import qualified Data.ByteString.UTF8 as U8 | |
import Network.HTTP.Types | |
import Network.Wai | |
import Network.Wai.Handler.Warp (run) | |
myApp :: Application | |
myApp _ = do | |
return $ ResponseBuilder status headers body | |
where | |
status = statusOK | |
headers = [(mk $ C8.pack "Content-Type", C8.pack "text/plain; charset=utf-8")] | |
body = fromByteString $ U8.fromString "Hello, 世界!" | |
main :: IO () | |
main = run port myApp | |
where | |
port = 8080 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment