Skip to content

NewYoungCode/HttpLinster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

//# HttpLib

//c++ 实现http server 2.0

//email: 718987717@qq.com

#include "HttpLinster.h"

using namespace HttpLib;

int main()

{

Server server;

std::printf("base dir at [%s]\n started !", server.WebRoot.c_str());


server.Get("/", [=](const Request& rq, Response& rp) {
	
	rp.Location = "/index.html";
});


server.Get("/test", [=](const  Request& rq, Response& rp) {
	rp.SetContent("{\"get\":\"LSkin Server 2.0!\"}", "application/json");
});


server.Post("/test", [=](const  Request& rq, Response& rp) {
	rp.SetContent("{\"post\":\"LSkin Server 2.0!\"}", "application/json");
	String body;
	rq.ReadStreamToEnd(body, 128); //读取body所有内容
	std::printf("%s\n", body.c_str());
});


server.Listen("0.0.0.0", 80);

return 0;

}

About

c++ 实现http server 2.0

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages