编译报pthread错误参考:https://zhuanlan.zhihu.com/p/91785848
起服务
#include "third/httplib/httplib.h"
using namespace std;
using namespace httplib;
int t=0;
int main()
{
Server server;
server.Get("/hello", [](const httplib::Request &req, httplib::Response &res)
{
t = t + 1;
cout << "第 " << t << " 次调用服务" << endl;
res.set_content("hello world !", "text/plain");
});
server.listen("0.0.0.0", 10000);
}
浏览器测试
-
http://服务机器ip:10000/hello
python测试
curl测试
curl介绍:https://www.ruanyifeng.com/blog/2019/09/curl-reference.html