From 8c2089dd8117835cfbfaed2c8f50cd34e666487f Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Mon, 25 Oct 2021 14:35:32 +0200 Subject: Added CMake install targets and reworked wwwroot folder structure. Signed-off-by: Toni Uhlig --- src/main.cpp | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 61407d8..8256717 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,7 +19,7 @@ int main(int argc, char ** argv) if (argc <= 1 || argc > 5) { - std::cout << "usage: cpp-web [HOST] [PORT] [STATIC-WWWROOT] [DYNAMIC-WWWROOT]" << std::endl; + std::cout << "usage: cpp-web [HOST] [PORT] [WWWROOT]" << std::endl; if (argc > 5) { return 1; @@ -34,6 +34,10 @@ int main(int argc, char ** argv) { port = atoi(argv[2]); } + if (argc > 3) + { + wwwroot = argv[3]; + } std::shared_ptr tmgr = std::make_shared(); std::shared_ptr cmgr = std::make_shared(); @@ -41,36 +45,22 @@ int main(int argc, char ** argv) { std::shared_ptr static_fs = std::make_shared(); - if (argc > 3) - { - if (static_fs->Scan(argv[3]) != true) - { - return 1; - } - } - std::cout << "Static fs: " << wwwroot << std::endl; - static_fs->Scan(wwwroot, {"html", "tmpl"}, true); + std::cout << "Static fs: " << wwwroot + "/static" << std::endl; + static_fs->Scan(wwwroot + "/static", {"html", "tmpl"}, true); cmgr->RegisterModule(std::make_shared("/static", static_fs)); } { Filesystem dynamic_fs; - if (argc > 4) - { - if (dynamic_fs.Scan(argv[4]) != true) - { - return 1; - } - } std::cout << "Dynamic fs: " << wwwroot << std::endl; dynamic_fs.Scan(wwwroot, {"html", "tmpl"}, false); tmgr->ParseTemplates(dynamic_fs); } - cmgr->RegisterModule(std::make_shared("/", "./pages", "index.html")); - cmgr->RegisterModule(std::make_shared("/blog", "./blog", "blog/index.html")); + cmgr->RegisterModule(std::make_shared("/", wwwroot + "/pages", "index.html")); + cmgr->RegisterModule(std::make_shared("/blog", wwwroot + "/blog", "blog/index.html")); if (cmgr->InitAll() == false) { -- cgit v1.2.3