------------------------------------------------------------------------------ -- Example for CGI programming in Curry: -- a form with a text input field and two event handlers ------------------------------------------------------------------------------ import HTML.Base main :: IO HtmlForm main = return $ form "Question" [htxt "Enter a string: ", textfield tref "", hrule, button "Reverse string" revhandler, button "Duplicate string" duphandler] where tref free revhandler env = return $ form "Answer" [h1 [htxt $ "Reversed input: " ++ reverse (env tref)]] duphandler env = return $ form "Answer" [h1 [htxt $ "Duplicated input: " ++ env tref ++ env tref]] -- Compile and install the CGI program by: -- 1. Install html package: -- > cypm add -d html && cypm install -- 2. Install executable `curry-makecgi`: -- > cypm install html -- 3. Install executable `html-cgi`: -- > cypm install html-cgi -- 4. Install executable `curry-cpnsd` (Curry Port Name Server)... -- > cypm install cpns -- ...and start it: -- > curry-cpnsd start -- -- Now you can compile the web script: -- > curry-makecgi -o ~/public_html/revdup.cgi RevDup -- If the web server is configured to execute CGI script, -- one can execute the web page.