admin 发表于 2019-4-2 14:59:57

小型的http服务器, 有什么推荐的吗, 不用处理web页面, 只是...

问题:小型的http服务器, 有什么推荐的吗, 不用处理web页面, 只是处理post数据,返回json字段.
解答:1.有个 HP-Socket 听说不错。
2.推荐cpp-httplib https://github.com/yhirose/cpp-httplib   
A C++11 header-only HTTP library. 单个文件C ++ 11仅限标头的HTTP / HTTPS服务器库。
#include <httplib.h>

int main(void)
{
    using namespace httplib;

    Server svr;

    svr.Get("/hi", [](const Request& req, Response& res) {
      res.set_content("Hello World!", "text/plain");
    });

    svr.Get(R"(/numbers/(\d+))", [&](const Request& req, Response& res) {
      auto numbers = req.matches;
      res.set_content(numbers, "text/plain");
    });

    svr.listen("localhost", 1234);
}

页: [1]
查看完整版本: 小型的http服务器, 有什么推荐的吗, 不用处理web页面, 只是...