forked from mmirman/haskogeneous
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.hs
50 lines (42 loc) · 1.26 KB
/
Main.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{-# LANGUAGE
TemplateHaskell
#-}
-----------------------------------------------------------------------------
-- |
-- Module : None
-- License : http://www.gnu.org/copyleft/gpl.html
--
-- Maintainer : [email protected]
-- Stability : experimental
-- Portability : probable
--
-- Just a test class for the main library.
module Main where
import Data.Functor
import Language.XmlHtml.HtmlTags
import Language.XmlHtml.XmlWriter
import Network
import Control.Concurrent
import System.IO
import System.Posix.Signals
handler sock = do
sClose sock
putStrLn "Ending Program"
main = withSocketsDo $ do
socket <- listenOn $ PortNumber 1338
installHandler sigINT (Catch $ handler socket) Nothing
sequence_ $ repeat $ do
(h,_,_) <- accept socket
forkIO $ do
t <- page <$> msg
hPutStr h $ t
hFlush h
hClose h
page content = "HTTP/1.0 200 OK\r\nContent-Length: "++show (length content)++"\r\n\r\n"++content++"\r\n"
msg = makeXml $
html $ do
liftIO $ putStrLn "hi - why is this printing so many times?"
body $ name "thisbody" $ do
h1 "AHA better syntax bitches!"
p $ name "dig" $ "HEHE and paragraphs!"
anchor $ name "dog" $ href "http://www.hulu.com/" $ "And links"