summaryrefslogtreecommitdiffhomepage
path: root/examples/cgi/cgi.cc
diff options
context:
space:
mode:
Diffstat (limited to 'examples/cgi/cgi.cc')
-rw-r--r--examples/cgi/cgi.cc33
1 files changed, 33 insertions, 0 deletions
diff --git a/examples/cgi/cgi.cc b/examples/cgi/cgi.cc
new file mode 100644
index 0000000..c2b4267
--- /dev/null
+++ b/examples/cgi/cgi.cc
@@ -0,0 +1,33 @@
+/*
+ cgi example
+ written by Amlal El Mahrouss.
+ licensed under GPL-2 license
+ */
+
+#include <fstream>
+#include <sstream>
+#include <stdx/cgi.hpp>
+#include <string>
+#include <filesystem>
+
+/* finally test it */
+int main(int argc, char** argv)
+{
+ // ... let's assume we serve data.
+
+ stdx::web::cgi_writer writer;
+ std::stringstream ss_file;
+
+ std::ifstream fp("index.html");
+
+ if (fp.good())
+ ss_file << fp.rdbuf();
+ else
+ ss_file << "<!DOCTYPE html>\n<html></html>";
+
+ fp.close();
+
+ writer.eval_html(ss_file);
+
+ return 0;
+}