cpp-httplib icon indicating copy to clipboard operation
cpp-httplib copied to clipboard

Static directory configuration

Open Keene-Chen opened this issue 4 years ago • 1 comments

Hi, I configured the static directory as per the example but was unsuccessful due to the first use, looked at the issues and did not find a solution. Hope to be able to get help, thank you

#include <iostream>
#include <httplib.h>

using namespace std;
using namespace httplib;

int main(void)
{
    Server svr;

    svr.Get("/", [&](const Request &req, Response &res)
            { svr.set_mount_point("/", "../resource"); });
    // or so? I don't know how to configure it 🤦‍♂️
    svr.set_mount_point("/", "../resource");

    svr.listen("0.0.0.0", 3000);

    return 0;
}

Keene-Chen avatar Dec 21 '21 12:12 Keene-Chen

Please see the following code. Hope it helps.

Server svr;

// Mount / to ./www directory
auto ret = svr.set_mount_point("/", "./www");
if (!ret) {
  // The specified base directory doesn't exist...
}

yhirose avatar Dec 21 '21 18:12 yhirose