Created
December 12, 2010 21:05
-
-
Save pheaver/738326 to your computer and use it in GitHub Desktop.
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
-- {-# OPTIONS_GHC -Wall #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
import Data.ByteString ( ByteString ) | |
import qualified Data.ByteString.Char8 as BS | |
import Data.Enumerator | |
import Data.Monoid | |
import Snap.Http.Server | |
import Snap.Http.Server.Config | |
import Snap.Iteratee | |
import Snap.Loader.Static (loadSnapTH) | |
import Snap.Types | |
-------------------------------------------------------------------------------- | |
load :: IO () | |
load = return () | |
cleanup :: () -> IO () | |
cleanup () = return () | |
runIt :: () -> Snap () | |
runIt () = do | |
xs <- runRequestBody iter | |
mapM_ writeBS xs | |
return () | |
iter :: Iteratee ByteString IO [ByteString] | |
iter = joinI $ | |
(\i -> takeNoMoreThan 10 i) $$ | |
consume | |
main :: IO () | |
main = do | |
let conf = completeConfig $ addListen (ListenHttp "0.0.0.0" 9000) mempty | |
(_, snap) <- $(loadSnapTH 'load 'cleanup 'runIt) | |
httpServe conf snap | |
-------------------------------------------------------------------------------- |
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
<html> | |
test<br> | |
<form target="foo" action='http://localhost:9000/' method='POST' enctype='multipart/form-data'> | |
<input name="a" value="default a" type="text"> | |
<input name="b" value="default b" type="text"> | |
<input type="checkbox" name="dry-run" value="yes">Dry run | |
<input name="file" type="file"> | |
<input type="submit"> | |
</form> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment