基于QT下的tufao小众型Http服务器环境搭建及demo
1 Tufao简介
项目地址:
项目地址:https://github.com/vinipsmaker/tufao
主页:
http://vinipsmaker.github.io/tufao/
项目地址:http://vinipsmaker.github.io/tufao/
介绍:
Tufão is a web framework for C++ that makes use of Qt’s object communication system (signals & slots).Tufão是一个C + +的Web框架,使用Qt的对象的通信系统(信号与槽)。
Features: 特性
High performance standalone server 高性能独立服务器
Cross-plataform support 跨平台支持
Good documentation 良好的文档
Support modern HTTP features 支持现代的HTTP特性
Persistent streams 持续流
Chunked entities 分块实体
100-continue status
WebSocket
HTTPS support 支持HTPPS
Flexible request router 灵活的路由请求
Static file server with support for conditional requests, partial download and automatic mime detection
静态文件服务器与条件请求支持,部分下载和自动检测
Plugin-based server to allow change the running code without restart the application
服务器基于插件机制,支持更改运行代码(?)而不用重启程序。
Flexible and secure session support 灵活和安全的会话支持
QtCreator’s plugin to allow create new applications rapidly QtCreator的插件,
以便快速创建新的应用程序
Lots of tests 经过了大量的测试
Timeout support 超时支持
C++11
It uses Ryan Dahl’s HTTP parser to provide good performance. 采用Ryan Dahl’s HTTP分析器以提供更好的性能You can generate documentation from the source code using Doxygen. The documentation will be put on the doc folder in the html and tex formats. There is also experimental support for Qt compressed help files.您可以使用Doxygen的源代码生成文档。该文件将在html和tex的格式被提上doc文件夹。也有对Qt的压缩帮助文件的实验性支持。
2 Tufao版本选择
目前(on 29 Jul 2018 )最新的版本是1.4.5,但是里面用了boost.http,弄了很久也没搞懂怎么配置,
如果有人知道请告知,感激不尽。
我目前用的是1.3.10版本。
3 环境搭建
3.0 下载Qt-MSVC2013 32位
1 我项目使用的是Qt5.6.3-MSVC2013版本(为了兼容XP系统),请安装Qt5.6.3-MSVC2013 32位的Qt
下载地址:http://mirror.bit.edu.cn/qtproject/archive/qt/5.6/5.6.3/qt-opensource-windows-x86-msvc2013-5.6.3.exe
3.1 下载Cmake
下载Cmakehttps://cmake.org/download,我使用的是3.16.0-rc3
3.2 生成sln解决方案
在tufao-1.3.10目录下新建build/Debug目录
启动CMake
如下图
点击Finish开始Config
完成后点击Generate生成sln解决方案
3.3 编译tufao.sln生成dll lib
启动VS2013 找到build/Debug下的tufao.sln解决方案
编译
在build/src/Debug目录下会产生tufao1d.lib tufao1.dl
3.4 启动QtCreator 新建GUI项目
1 新建项目TufaoStudy项目,把Tufao-1.3.10目录下的
src拷贝到TufaoStudy目录下
2 TufaoStudy.pro文件
…
#-------------------------------------------------
Project created by QtCreator 2019-11-29T19:50:41
#-------------------------------------------------
QT += core gui
QT += network
CONFIG += C++11 TUFAO1
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = TufaoStudy
TEMPLATE = app
INCLUDEPATH += ./src \
SUBDIRS +=
src
SOURCES += main.cpp
widget.cpp
HEADERS += widget.h
FORMS += widget.ui
LIBS += -L$$PWD/lib/ -ltufao1d
RESOURCES +=
resources.qrc
…
把tufao编译生成tufao1d.lib tufao1d.dll拷贝到相应目录
3 编译运行程序TufaoStudy.exe
4 在浏览器输入localhost:8080查看exe变化 浏览器会返回相应信息
输入:http://localhost:8080
输入:http://localhost:8080/test
HttpServer按钮会有所显示隐藏
本工程的源码
项目地址:https://download.youkuaiyun.com/download/thinkpadlove/12006719
由于优快云上传资源默认是5积分 没有积分的可以评论留下邮箱或者联系我qq:1017471803