Skip to content

eatbreads/web-frame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yazi-web

一个轻量级的web库, 带上注释好理解

example

server.cpp

#include <iostream>
using namespace std;

#include <web/Server.h>
using namespace yazi::web;

void hello(const Request & req, Response & resp)
{
    string name = req.get("name");
    string age = req.get("age");
    string host = req.user_host();
    resp.html("hello, " + name + "," + age + "," + host);
}

void reply(const Request & req, Response & resp)
{
    string name = req.post("name");
    int age = req.post("age");
    
    Json json;
    json["name"] = name;
    json["age"] = age;
    resp.json(json.str());
}

int main()
{
    Server * server = Singleton<Server>::instance();
    server->listen("", 8080);
    server->bind("/hello", hello);
    server->bind("/reply", reply);
    server->start();
    return 0;
}

About

c++实现的web框架,内置反射,json解析器,线程池,reactor,支持post,get和uploud等

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors