Module HTML.CgiServer

This library contains the implementation of the server based on CGI to implement dynamic web pages.

Author: Michael Hanus

Version: October 2017

Summary of exported operations:

runFormServerWithKey :: String -> String -> IO HtmlForm -> IO ()   
The server implementing an HTML form (possibly containing input fields).
runFormServerWithKeyAndFormParams :: String -> String -> [FormParam] -> IO HtmlForm -> IO ()   
The server implementing an HTML form (possibly containing input fields).
intForm :: IO HtmlForm -> IO ()   
Execute an HTML form in "interactive" mode.
intFormMain :: String -> String -> String -> String -> Bool -> String -> IO HtmlForm -> IO ()   
Execute an HTML form in "interactive" mode with various parameters.

Exported operations:

runFormServerWithKey :: String -> String -> IO HtmlForm -> IO ()   

The server implementing an HTML form (possibly containing input fields). It receives a message containing the environment of the client's web browser, translates the HTML form w.r.t. this environment into a string representation of the complete HTML document and sends the string representation back to the client's browser by binding the corresponding message argument.

Example call:
(runFormServerWithKey url cgikey hformact)
Parameters:
  • url : the URL of this executable.
  • cgikey : a unique key to identify this CGI script (used for safe storing of event handlers in this server)
  • hformact : an IO action returning an HTML form

runFormServerWithKeyAndFormParams :: String -> String -> [FormParam] -> IO HtmlForm -> IO ()   

The server implementing an HTML form (possibly containing input fields). It receives a message containing the environment of the client's web browser, translates the HTML form w.r.t. this environment into a string representation of the complete HTML document and sends the string representation back to the client's browser by binding the corresponding message argument.

Example call:
(runFormServerWithKeyAndFormParams url cgikey formparams hformact)
Parameters:
  • url : the URL of this executable.
  • cgikey : a unique key to identify this CGI script (used for safe storing of event handlers on the web server)
  • formparams : form parameters added to the initial and all subsequent forms
  • hformact : an IO action returning an HTML form

intForm :: IO HtmlForm -> IO ()   

Execute an HTML form in "interactive" mode.

intFormMain :: String -> String -> String -> String -> Bool -> String -> IO HtmlForm -> IO ()   

Execute an HTML form in "interactive" mode with various parameters.

Example call:
(intFormMain baseurl basecgi reldir cginame forever urlparam hformact)
Parameters:
  • baseurl : the base URL where this script is accessible for clients
  • basecgi : the base directory in the local file system where this script should stored for execution
  • reldir : the relative path added to baseurl and basecgi
  • cginame : the name of the executable cgi script
  • forever : True if the interactive execution should not be terminated when the final web page (without a handler) is shown
  • urlparam : the URL parameter for the initial call to the cgi script
  • hformact : IO action returning the HTML form