summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-03-29 20:27:48 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-03-29 20:27:48 +0100
commit79c2769714d1b41416360cbb23a64f5cf68abc1f (patch)
tree2641bd617447c323839e26df10a4d1e919d77bc7 /examples
parent02856414d220a5a4cb8d196de490698dd0cc0c70 (diff)
module: add: CGI header.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'examples')
-rw-r--r--examples/cgi/CMakeLists.txt12
-rw-r--r--examples/cgi/cgi.cc33
-rw-r--r--examples/must_pass/CMakeLists.txt2
3 files changed, 46 insertions, 1 deletions
diff --git a/examples/cgi/CMakeLists.txt b/examples/cgi/CMakeLists.txt
new file mode 100644
index 0000000..6a93acf
--- /dev/null
+++ b/examples/cgi/CMakeLists.txt
@@ -0,0 +1,12 @@
+
+cmake_minimum_required(VERSION 3.15...3.31)
+
+project(
+ CGI
+ VERSION 1.0
+ LANGUAGES CXX)
+
+add_executable(CGI cgi.cc)
+
+set_property(TARGET CGI PROPERTY CXX_STANDARD 20)
+target_include_directories(CGI PUBLIC ../../lib)
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;
+}
diff --git a/examples/must_pass/CMakeLists.txt b/examples/must_pass/CMakeLists.txt
index 0075ad5..6fcd411 100644
--- a/examples/must_pass/CMakeLists.txt
+++ b/examples/must_pass/CMakeLists.txt
@@ -9,4 +9,4 @@ project(
add_executable(MustPass must_pass.cc)
set_property(TARGET MustPass PROPERTY CXX_STANDARD 20)
-target_include_directories(MustPass PUBLIC ../lib)
+target_include_directories(MustPass PUBLIC ../../lib)