上传测试文件
parent
0edab63028
commit
28c621cad6
@ -0,0 +1,32 @@
|
||||
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");
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 75 MiB |
File diff suppressed because one or more lines are too long
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
@ -0,0 +1,32 @@
|
||||
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");
|
||||
}
|
Loading…
Reference in New Issue