Examples‎ > ‎

Web CGI

To create CGI's we must declare them using the macro DECLARE_CGI

DECLARE_CGI(CgiExample)

And then we implement the CGI function in any source file.

VOID CgiExample(E_SOCKET* pSocket, STRING strParams, STRING strForm)
{
STRING strName;
STRING strValue;
STRING strLine = strParams;

WebSendResponse(pSocket, WEB_OK);
eSocketPuts(pSocket, "<HTML>" LF "<BODY>" LF);
if (CgiExtractParam(&strName, & strValue, &strLine))
{
eSocketPrintf(pSocket, "Your parameter is %s = %s\n", strName, strValue);
}
eSocketPuts(pSocket, "</BODY>" LF "</HTML>" LF );
}

And finally, you must include your CGI in the CGIs static table.

const CGI cgiTable[] =
{
"example", CgiExample, "Test the CGI feature" },
}

To call your CGI function, you must get the URL:

http://<ipaddress>/example?name=Jordi

And then you will get the answer:

Your parameter is name = Jordi
Comments