没有合适的资源?快使用搜索试试~ 我知道了~
Centos7安装wfrest详情,带测试源码
需积分: 10 1 下载量 148 浏览量
2022-10-27
09:29:12
上传
评论
收藏 145KB DOCX 举报
温馨提示
试读
11页
c++根据wfrest框架编写服务端,测试图片上传源码
资源详情
资源评论
资源推荐
c++ http 框架 wfrest 服务器安装和使用
1. Cent OS 7 升级默认安装程序
gcc,g++<11.2.1>
Cmake<3.24.2>
2. 安装 wfrest workflow
git clone https://github.com/sogou/workflow.git
cd workflow/
cmake .
make -j8 && make install
git clone --recursive https://github.com/wfrest/wfrest.git
cd wfrest
cmkae .
make -j8 && make install
3. 编译测试服务器
g++ -o test main.cpp -std=c++11 -lwfrest -lworkflow -lz
-Wl,-rpath=/usr/local/lib64
./test
注意这里安装的 workflow 和 wfrest 有可能安装在/usr/local/lib64 目录下,网上很多都是装
在 /usr/local/lib 下 , 目 录 错 误 会 报 类 似 错 误 : ./test: error while loading shared libraries:
libworkflow.so.0: cannot open shared object file: No such file or directory
4. 测试程序(main.cpp)
#include <iostream>
#include <wfrest/HttpServer.h>
using namespace wfrest;
using namespace std;
int main()
{
HttpServer svr;
//curl -v http://ip:port/hello
svr.GET("/hello", [](const HttpReq *req, HttpResp *resp)
{
cout << "curl hello ...... " << endl;
resp->String("world\n");
});
// curl -v http://ip:port/data
svr.GET("/data", [](const HttpReq *req, HttpResp *resp)
{
std::string str = "Hello world";
cout << "curl data ...... " << str << endl;
resp->String(std::move(str));
});
// curl -v http://ip:port/post -d 'post hello world'
svr.POST("/post", [](const HttpReq *req, HttpResp *resp)
{
// reference, no copy here
std::string& body = req->body();
fprintf(stderr, "post data : %s\n", body.c_str());
});
if(svr.start(8888) == 0)
{
getchar();
svr.stop();
}
else
{
fprintf(stderr, "Cannot start server");
exit(1);
}
return 0;
}
5. 效果
剩余10页未读,继续阅读
liln0530
- 粉丝: 15
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 通道处理过程的模拟通常涉及对通道处理机制的理解与实现.txt
- Flume进阶-自定义拦截器jar包
- Dubins曲线算法讲解和在运动规划中的使用.pdf
- 上市公司-股票性质数据-工具变量(民企、国企、央企)2003-2022年.dta
- 上市公司-股票性质数据-工具变量(民企、国企、央企)2003-2022年.xlsx
- Reeds+Shepp曲线算法讲解和实现.pdf
- 毕业设计基于SpringBoot+MyBatisPlus+MySQL+Vue的外卖配送信息系统源代码+数据库
- 词向量(Word Embeddings)是自然语言处理(NLP)领域的一种重要技术.txt
- Surfer,线性函数
- MyBatis 的动态 SQL 是其核心特性之一.txt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0