summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-03-30 12:01:02 +0200
committerAmlal El Mahrouss <amlal@nekernel.org>2025-03-30 12:01:02 +0200
commit5b1b2019c33d0f0472081b64025eba034f3004fd (patch)
tree173369ed713c6041299a5953eae674db5514b67c /examples
parent57426fa79796120babf9e19c72281891d1e35a63 (diff)
lib/cgi.hpp: better 'Server' field, no spaces anymore (according to std)
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'examples')
-rw-r--r--examples/cgi/cgi.cc61
1 files changed, 60 insertions, 1 deletions
diff --git a/examples/cgi/cgi.cc b/examples/cgi/cgi.cc
index c2b4267..7897122 100644
--- a/examples/cgi/cgi.cc
+++ b/examples/cgi/cgi.cc
@@ -10,7 +10,66 @@
#include <string>
#include <filesystem>
+const std::string g_file_list = R"(
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="UTF-8">
+ <title>Uh Oh!</title>
+ <style>
+ body {
+ font-family: monospace;
+ background: white;
+ color: black;
+ margin: 2em;
+ }
+ h1 {
+ font-size: 1.5em;
+ }
+ hr {
+ border: none;
+ border-top: 1px solid #ccc;
+ }
+ table {
+ width: 100%;
+ border-collapse: collapse;
+ }
+ td {
+ padding: 0.2em 0.5em;
+ }
+ td:first-child {
+ white-space: nowrap;
+ }
+ a {
+ color: blue;
+ text-decoration: none;
+ }
+ a:hover {
+ text-decoration: underline;
+ }
+ </style>
+</head>
+<body>
+ <h1>Uh Oh!</h1>
+ <address>No HTML file were found on this directory, please seek help from your systems administrator.</address>
+ <hr>
+ <table>
+ <tr><th>Name</th></tr>
+ <tr><td colspan="3"><hr></td></tr>
+
+ <tr>
+ <td><a href="javascript:window.location.reload();">Refresh</a></td>
+ </tr>
+
+ <tr><td colspan="3"><hr></td></tr>
+ </table>
+ <address>stdx's Common Gateway Server.</address>
+</body>
+</html>
+)";
+
/* finally test it */
+/* @brief this stub loads a 'index.html' or returns an error message if not found. */
int main(int argc, char** argv)
{
// ... let's assume we serve data.
@@ -23,7 +82,7 @@ int main(int argc, char** argv)
if (fp.good())
ss_file << fp.rdbuf();
else
- ss_file << "<!DOCTYPE html>\n<html></html>";
+ ss_file << g_file_list;
fp.close();