// test.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "cgi.h"

int 
main(int argc, char* argv[])
{
   fprintf(stdout, "Content-type: text/html\r\n\r\n");
   fflush(stdout);

   cgi< > formData;

   char * name = formData["name"];
   if(name) {
      fprintf(stdout, "<HTML><HEAD><TITLE>Test</TITLE></HEAD><BODY BGCOLOR=\"WHITE\">"
                      "<H1>Hello, %s</H1>"
                      "</BODY></HTML>", name);
      fflush(stdout);
   }
   else {
      fprintf(stdout, "<HTML><HEAD><TITLE>Test</TITLE></HEAD><BODY BGCOLOR=\"WHITE\">"
                      "GET <FORM METHOD=GET ACTION=/cgi-bin/test.exe>Name:"
                      "<input type=text name=name><input type=submit></FORM>"
                      "POST <FORM METHOD=POST ACTION=/cgi-bin/test.exe>Name:"
                      "<input type=text name=name><input type=submit></FORM>"
                      "</BODY></HTML>");
      fflush(stdout);
   }
}

