Skip to content

BigBookPlus/qthttpserver-sample-with-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

qthttpserver-sample-with-client

This is a DIY sample code of the qt-labs/qthttpserver lib. In this demo, we start a simple server which response to a GET / POST request, and do a simple http post with json-format body.

Build QtHttpServer

please refer to qt-labs/qthttpserver, we check out branch 5.15 for we using Qt5.

Built as instructions, and copy files into our your Qt dirs. QtCreator is always recommended.

Build this repo

Please modify the following line in CMakeLists.txt file, replace Qt5_DIR with your own Qt installation dir.

set(Qt5_DIR D:/Qt/Qt5.12.6/5.12.6/msvc2017_64/lib/cmake/Qt5)

simply as usual,

mkdir build && cd build
cmake ..
make

TEST

to start the server,

./server 

open internet browser and try http://127.0.0.1:8888, we can see a message Hello QtHttpServer.

to do a http post, run client

./client

If everything goes well, server will print the posted json body from client and client will print the response message from server.

References

How to send a POST request in Qt with the JSON body

qt-labs/qthttpserver

My Blog post:'QtHttpServer Demo with Client Post'