diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-08-02 01:29:15 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-08-02 01:29:15 +0100 |
| commit | 678f457a9797ae064634f8ba2a83b156f2892871 (patch) | |
| tree | 31e5d6625e16dd5842022e5d99de4dd51ea55277 /dev/examples/cgi | |
| parent | 4dbb5cc1283eed26cb9b66600fe9bb594aad8ef3 (diff) | |
refactor! breaking API changes of SOCL, also reworked must_pass helpers, and added one for the fix parser.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/examples/cgi')
| -rw-r--r-- | dev/examples/cgi/cgi.cc | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/dev/examples/cgi/cgi.cc b/dev/examples/cgi/cgi.cc index b4c0b34..2cb8f3a 100644 --- a/dev/examples/cgi/cgi.cc +++ b/dev/examples/cgi/cgi.cc @@ -1,4 +1,4 @@ -/* +/* cgi example written by Amlal El Mahrouss. licensed under the MIT license @@ -9,12 +9,12 @@ #include <sstream> #include <string> -const std::string g_not_found = R"( +const std::string error_html = R"( <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> - <title>error | snu-lib</title> + <title>Error | SOCL</title> <style> body { font-family: monospace; @@ -62,7 +62,7 @@ const std::string g_not_found = R"( <tr><td colspan="3"><hr></td></tr> </table> - <address>snu's Common Gateway Server.</address> + <address>SOCL's Common Gateway Server.</address> </body> </html> )"; @@ -71,21 +71,12 @@ const std::string g_not_found = R"( /* @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. + snu::cgi::basic_writer<> writer; - snu::cgi::cgi_writer writer; - std::stringstream ss_file; + std::stringstream ss_file; + ss_file << error_html; - std::ifstream fp("index.html"); - - if (fp.good()) - ss_file << fp.rdbuf(); - else - ss_file << g_not_found; - - fp.close(); - - writer.eval_html(ss_file); + writer.html(ss_file); return 0; } |
