基於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.csdn.net/download/thinkpadlove/12006719

由於CSDN上傳資源默認是5積分 沒有積分的可以評論留下郵箱或者聯繫我qq:1017471803

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章