[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/expresscpp/expresscpp/master/test/static_file_middleware.cpp [Back]  [Original]

#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/fetch.hpp" #include "expresscpp/middleware/serve_static_provider.hpp" #include "gtest/gtest.h" #include "nlohmann/json.hpp" using namespace expresscpp; constexpr uint16_t port = 8081u; TEST(StaticFileMiddleware, ServeIndexHtml) { auto expresscpp = std::make_shared(); // 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