29 lines
1.1 KiB
Plaintext
29 lines
1.1 KiB
Plaintext
// Copyright (C) 2022 The Qt Company Ltd.
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
|
|
|
|
/*!
|
|
\ingroup qthttpserver-examples
|
|
\title Simple HTTP Server
|
|
\examplecategory {Web Technologies}
|
|
\brief Simple example of how to set up an HTTP server.
|
|
\image browserwindow.png
|
|
|
|
This example shows how to set up a server using the QHttpServer class.
|
|
The server is bound to a QTcpServer listening to a port with the bind()
|
|
function, and the \c route() function is used to add a handler for each
|
|
of several different incoming URLs. For one of the URLs, "/auth",
|
|
\l{RFC 7617}{Basic HTTP Authentication} is used.
|
|
|
|
\snippet simple/main.cpp HTTPS Configuration example
|
|
In the above example \c QSslConfiguration is used to show how to create
|
|
an SSL configuration for a QHttpServer to serve HTTPS traffic.
|
|
|
|
\snippet simple/main.cpp Using addAfterRequestHandler()
|
|
The above example shows how to use the \c addAfterRequestHandler() function of the
|
|
QHttpServer to change the QHttpServerResponse object after it has been handled
|
|
by the \c route() function. It demonstrates how HTTP headers can be added to the
|
|
response.
|
|
|
|
\example simple
|
|
*/
|