コード例 #1
0
int main(int argc, char *argv[]) 
{
    CCgiRequest Request(argc, argv);
    CCgiResponse Response;

    // write out the Content-type header
    Response.WriteHeader();

    // Get the multimap.  see http://www.sgi.com/Technology/STL/Multimap.html
    // on how to manipulate multimaps
    TCgiEntries Entries = Request.GetEntries();

    // this program expects queries of the form cgidemo?name=Fred
    // the following line extracts the "Fred"
    string Name;
    TCgiEntries::const_iterator iName = Entries.find("name");
    if (iName == Entries.end()) Name = "World"; 
    else Name = iName->second;

    // print out the results
    Response.out() << "<html><body>Hello, " << Name;
    Response.out() << "</body></html>" << endl;
    Response.Flush();

    return 0;  
}
コード例 #2
0
ファイル: demo_html.cpp プロジェクト: DmitrySigaev/ncbi
static int s_Demo(void)
{
    CCgiResponse Response; // Used to write out the html
    CNodeRef     Html;     // The following are tags used in the page.
    CNodeRef     Body;
    CNodeRef     Form;

    try {
        // Write out the Content-type header
        Response.WriteHeader();

        // Create the tags
        Html = new CHTML_html();
        Body = new CHTML_body();
        Form = new CHTML_form("cgidemo", CHTML_form::eGet);

        // Stick them together
        Html->AppendChild(Body);
        Body->AppendChild(Form);
        Form->AppendChild(new CHTML_text("name"));
        Form->AppendChild(new CHTML_submit("Submit"));

        // Print out the results
        Html->Print(Response.out());
        Response.Flush();

        return 0;  
    }
    // Check to see if there were any errors
    catch (exception& exc) { 
        // Deallocate memory in case of error
        NcbiCerr << "\n" << exc.what() << NcbiEndl;
    }
    // Error
    return 1;
}