#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("DQM online webpage")) << endl;
      cout << body() << endl;
      
      
      
      
      cout << " <div align=""center""><center>"  << endl;
      cout << "<table border=""0"" cellspacing=""11"" bgcolor=""#000000"">"  << endl;
      cout << "<tr>" << endl;
      cout << "  <td><p align=""center""><font color=""#FFFFFF"" size=""7"">TestBeam DQM web Page</font></p>"  << endl;
      cout << "  </td> </tr> </table> </center></div>"  << endl;
    

      
            
      string run,num_run;
      int pos,stringsize;
      
      system("ls *.root | sort -n > filelist");
      ifstream stream2 ("filelist");
      if (stream2.is_open()) {
      
      	while (stream2.good() ) {
		stream2 >> run;
		stringsize=run.size();
		pos = run.find(".");
		if (pos>1) {
		  run = run.substr (0,pos);

      		  // Print out the submitted element
         	  cout << " " << " <a href=""" << run << "f.html"" target=""_top"" >" << run << "</a> " << endl;
		}
      	}
      }

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

