[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/hpsware/expresscpp/master/example/serve_static.cpp [Back]  [Original]

// https://expressjs.com/en/resources/middleware/serve-static.html #include #include #include #include #include #include #include "boost/uuid/uuid_generators.hpp" #include "boost/uuid/uuid_io.hpp" #include "expresscpp/console.hpp" #include "expresscpp/expresscpp.hpp" #include "expresscpp/middleware/serve_static_provider.hpp" using namespace expresscpp; int main() { ExpressCpp expresscpp; Console::setLogLevel(LogLevel::kDebug); // create temp folder for html files const auto uuid_ = boost::uuids::random_generator()(); const auto tmp_folder = std::filesystem::temp_directory_path(); const std::string doc_root = tmp_folder.string() + "/www-" + boostUUIDToString(uuid_); std::filesystem::create_directory(doc_root); std::string index_html_content = R"( This is the title of the webpage!

This is a paragraph.

)"; std::string index_doc_content = R"({"status": "ok"})"; // create html files { std::filesystem::path path_to_index_html = doc_root + "/index.html"; std::ofstream index_html_file(path_to_index_html); index_html_file
Web Proxy Viewer  |  New URL  |  Original Page