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.
30 lines
821 B
C++
30 lines
821 B
C++
#pragma once
|
|
#include "../cpp-httplib/httplib.h"
|
|
#include <string>
|
|
#include <windows.h>
|
|
#include <vector>
|
|
|
|
using namespace std;
|
|
using namespace httplib;
|
|
|
|
class CHttplibServer
|
|
{
|
|
public:
|
|
CHttplibServer();
|
|
virtual ~CHttplibServer();
|
|
bool StartHttpServer(string SvrFilesDir="",bool bAsync=true);
|
|
void SetFilesDir(string Dir) { m_SvrFilesDir = Dir; }
|
|
private:
|
|
string m_SvrFilesDir;//服务器文件所在文件夹
|
|
string m_SvrIP = "0.0.0.0";
|
|
int m_Port = 1234;
|
|
public:
|
|
virtual void OnCommand(string cmd, Response& res);
|
|
private:
|
|
void OnDownloadFile(const Request& req, Response& res);
|
|
void OnCommandBase(const Request& req, Response& res);
|
|
void OnCommand_GetFileList(const Request& req, Response& res);//获取服务器文件夹的所有文件名
|
|
vector<string> get_file_names(const string & Dir);//获取文件夹内的所有文件名
|
|
};
|
|
|