Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
curry-packages
html
Commits
6e108d09
Commit
6e108d09
authored
Jan 22, 2018
by
Michael Hanus
Browse files
Type signatures added, example updated
parent
c2f595e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
examples/RevDup.curry
View file @
6e108d09
...
...
@@ -23,4 +23,4 @@ main = return $ form "QUESTION" $
-- Install the CGI program by:
-- curry makecgi
-cpm
-o ~/public_html/revdup.cgi RevDup
-- curry makecgi -o ~/public_html/revdup.cgi RevDup
src/HtmlCgi.curry
View file @
6e108d09
...
...
@@ -30,6 +30,7 @@ import List
--------------------------------------------------------------------------
-- Should the log messages of the server stored in a log file?
withCgiLogging :: Bool
withCgiLogging = True
--------------------------------------------------------------------------
...
...
@@ -75,6 +76,7 @@ readCgiServerMsg handle = do
-- "-loadbalance
<t>
": specifies kind of load balancing (see makecurrycgi)
-- Current possible values for
<t>
:
-- "no|standard|multiple"
submitForm :: IO ()
submitForm = do
args
<-
getArgs
let
(
serverargs
,
lb
,
rargs) =
stripServerArgs
""
NoBalance
args
...
...
@@ -137,6 +139,7 @@ runCgiServerCmd portname cmd = case cmd of
_
-
>
error "HtmlCgi.runCgiServerCmd: called with illegal command!"
--- Translates a cgi progname and key into a name for a port:
cgikey2portname :: String -> String
cgikey2portname cgikey =
concatMap (\c->if isAlphaNum c then [c] else []) cgikey
...
...
@@ -220,6 +223,7 @@ noHandlerPage cgiurl urlparam =
--- that are transmitted to the application program.
--- Currently, it contains only a selection of all reasonable variables
--- but this list can be easily extended.
cgiServerEnvVars :: [String]
cgiServerEnvVars =
["PATH_INFO","QUERY_STRING","HTTP_COOKIE","REMOTE_HOST","REMOTE_ADDR",
"REQUEST_METHOD","SCRIPT_NAME","SERVER_NAME","SERVER_PORT"]
...
...
@@ -228,6 +232,7 @@ cgiServerEnvVars =
-- If the port of the application server is not available within the timeout
-- period, we assume that the application server does not exist and we start
-- a new one.
scriptServerTimeOut :: Int
scriptServerTimeOut = 1000
-- send a message to the script server and return the connection handle,
...
...
@@ -238,6 +243,8 @@ trySendScriptServerMessage portname msg =
maybe failed (\h -> hPutStrLn h (showQTerm msg) >> hFlush h >> return h)
-- submit an initial web page request to a server or restart it:
submitToServerOrStart :: String -> String -> LoadBalance -> String -> String
-> String -> [(String,String)] -> IO ()
submitToServerOrStart url serverargs loadbalance pname scriptkey
serverprog cgiServerEnv =
connectToSocketRepeat scriptServerTimeOut done 0 completeportname >>=
...
...
@@ -332,6 +339,7 @@ copyOutputAndClose h = do
else done
-- Puts a line to stderr:
putErrLn :: String -> IO ()
putErrLn s = hPutStrLn stderr s >> hFlush stderr
------------------------------------------------------------------------------
...
...
@@ -393,6 +401,7 @@ includeCoordinates ((tag,val):cenv)
-- get n chars from stdin:
getNChar :: Int -> IO String
getNChar n = if n
<
=0
then
return
""
else
do
c
<
-
getChar
cs
<
-
getNChar
(
n-1
)
...
...
@@ -400,6 +409,7 @@ getNChar n = if n<=0 then return ""
------------------------------------------------------------------------------
---
The
name
of
the
file
to
register
all
cgi
servers.
cgiServerRegistry
::
String
cgiServerRegistry =
"/tmp/CURRY_CGI_REGISTRY"
--
Register
a
new
cgi
server
process
(
for
global
management
of
all
such
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment