2024-12-27 12:59:20 -05:00

94 lines
2.1 KiB
C++

#include "HttpServer.h"
CHttpServer::CHttpServer()
{
mHttpServer = new QHttpServer;
mHttpServer->route("/", []()
{
// return " <!DOCTYPE html>\
// <html>\
// <head>\
// <title>Page Title</title>\
// </head>\
// <body>\
// \
// <h1>This is a Heading</h1>\
// <p>This is a paragraph.</p>\
// \
// </body>\
// </html>";
// return " <!DOCTYPE html>\
// <html>\
// <body>\
// \
// <h1>My First JavaScript</h1>\
// \
// <button type=\"button\" \
// onclick=\"document.getElementById('demo').innerHTML = Date()\">\
// Click me to display Date and Time.</button>\
// \
// <p id=\"demo\"></p>\
// \
// </body>\
// </html> ";
return "<!DOCTYPE html>\
<html>\
<body>\
\
<h2>SVG rect Element</h2>\
\
<svg width=\"300\" height=\"130\">\
<rect width=\"200\" height=\"100\" x=\"10\" y=\"10\" rx=\"20\" ry=\"20\" fill=\"blue\" />\
Sorry, your browser does not support inline SVG. \
</svg>\
\
</body>\
</html>";
});
mHttpServer->route("/test", []()
{
return " <!DOCTYPE html>\
<html>\
<head>\
<title>Page Title</title>\
</head>\
<body>\
\
<h1>This is a Heading</h1>\
<p>This is a paragraph.</p>\
\
</body>\
</html>";
});
const auto port = mHttpServer->listen(QHostAddress::Any,8080);
qDebug("Server Opened");
}
CHttpServer::~CHttpServer()
{
delete mHttpServer;
}