You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
748 B
Plaintext

void CHttplibServer::OnDownloadFile(const Request& req, Response& res)
{
if (m_SvrFilesDir.empty())
m_SvrFilesDir = GetExeDir() + SERVER_FILE_DIR;
string FileName = req.matches[1];
string file_path = m_SvrFilesDir+"/"+FileName;
if (!bFileExist(file_path))
{
res.status = 404;
res.set_content("File not found", "text/plain");
return;
}
res.set_file_content(file_path);
return;
}
void CHttplibServer::OnCommand_GetFileList(const Request& req, Response& res)
{
if (m_SvrFilesDir.empty())
m_SvrFilesDir = GetExeDir() + SERVER_FILE_DIR;
vector<string> NameVec = get_file_names(m_SvrFilesDir);
string sRespon;
for (auto const & Name: NameVec)
{
sRespon += Name;
sRespon += ",";
}
res.set_content(sRespon, "text/plain");
}