#include "third/httplib/httplib.h"
#include "third/nlohmann/json.hpp"
using namespace std;
using namespace httplib;
using namespace nlohmann;
int t=0;
int main()
{
Server server;
server.Get("/hello", [](const httplib::Request &req, httplib::Response &res)
{
t = t + 1;
cout << "第 " << t << " 次调用服务" << endl;
json j = {
{"name", "bei_jing"},
{"time", "xx"},
{"score",{"top-1", 0.9, "xx.jpg"}}
};
res.set_content(j.dump(), "text/plain");
});
server.listen("0.0.0.0", 10000);
}
浏览器
Python
Curl
服务终端打印