#include <iostream>
#include <vector>
#include <string>

#include "cgicc/Cgicc.h"
#include "cgicc/HTTPHTMLHeader.h"
#include "cgicc/HTMLClasses.h"

using namespace std;
using namespace cgicc;

int main(int argc, char **argv)
{
   try {
      Cgicc cgi;

      // Send HTTP header
      cout << HTTPHTMLHeader() << endl;

      // Set up the HTML document
      cout << html() << head(title("cgicc example")) << endl;
      cout << body() << endl;
            
      string run;      
      system("ls > filelist");
      ifstream stream2 ("filelist");
      if (stream2.is_open()) {
      
      	while (stream2.good() ) {
		stream2 >> run;

      		// Print out the submitted element
         	cout << "Your name: " << run << endl;


      	}
      }

      // Close the HTML document
      cout << body() << html();
   }
   catch(exception& e) {
      // handle any errors - omitted for brevity
   }
}

