ARTICLE DETAIL

资讯详情

深耕网站建设与运营推广的一线实战洞察。

httplb 服务器

httplb 服务器
#include <iostream>
#include "httplib.h"    
using namespace std;
using namespace httplib;
int main(){Server svr;svr.Get("/",[](const Request& req,Response& res){res.set_content("Hello World", "text/plain");});svr.Get("/gret/(.*)",[](const Request& req,Response& res){auto name=req.matches[1];res.set_content(name,"text/plain");}); svr.Get("/json", [](const Request& req, Response& res) {res.set_content(R"({"status": "ok"})", "application/json");});cout<<"Server running at http:127.0.0.1\n";svr.listen("0.0.0.0", 80);}

 

返回列表