Tests serveur HTTP

This commit is contained in:
jfmartel 2024-12-27 12:59:20 -05:00
parent 918d2d8fdb
commit 3fb8de2ea7
4 changed files with 80 additions and 7 deletions

View File

@ -1,6 +1,6 @@
#QT += Network #QT += Network
#QT += gui declarative network #QT += gui declarative network
QT += gui network serialport mqtt QT += gui network serialport mqtt websockets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
#CONFIG += console #CONFIG += console

View File

@ -6,11 +6,79 @@ CHttpServer::CHttpServer()
mHttpServer = new QHttpServer; mHttpServer = new QHttpServer;
mHttpServer->route("/", []() mHttpServer->route("/", []()
{ {
qDebug("Test");
return "Ja Mon CB!!!!";
// 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); const auto port = mHttpServer->listen(QHostAddress::Any,8080);

View File

@ -47,7 +47,7 @@ public:
CLoraModuleInterface *mChaletLoraModuleInterface; CLoraModuleInterface *mChaletLoraModuleInterface;
// CAppIconWidget mAppWidget; // CAppIconWidget mAppWidget;
// CHttpServer mHttpServer; CHttpServer mHttpServer;
CIspindelDevice *mIspindelDevice; CIspindelDevice *mIspindelDevice;

View File

@ -34,6 +34,7 @@ public:
QCheckBox *mUseLoraIFCheckBx; QCheckBox *mUseLoraIFCheckBx;
QSpinBox *mLoraChannelSpinBx; QSpinBox *mLoraChannelSpinBx;
QLabel *label_4; QLabel *label_4;
QCheckBox *checkBox;
void setupUi(QWidget *CLoraSettingsGui) void setupUi(QWidget *CLoraSettingsGui)
{ {
@ -48,7 +49,7 @@ public:
label->setFont(font); label->setFont(font);
groupBox = new QGroupBox(CLoraSettingsGui); groupBox = new QGroupBox(CLoraSettingsGui);
groupBox->setObjectName(QString::fromUtf8("groupBox")); groupBox->setObjectName(QString::fromUtf8("groupBox"));
groupBox->setGeometry(QRect(50, 120, 221, 191)); groupBox->setGeometry(QRect(110, 170, 221, 191));
label_2 = new QLabel(groupBox); label_2 = new QLabel(groupBox);
label_2->setObjectName(QString::fromUtf8("label_2")); label_2->setObjectName(QString::fromUtf8("label_2"));
label_2->setGeometry(QRect(10, 40, 71, 16)); label_2->setGeometry(QRect(10, 40, 71, 16));
@ -89,9 +90,12 @@ public:
mLoraChannelSpinBx->setMinimum(1); mLoraChannelSpinBx->setMinimum(1);
mLoraChannelSpinBx->setMaximum(65535); mLoraChannelSpinBx->setMaximum(65535);
mLoraChannelSpinBx->setValue(6); mLoraChannelSpinBx->setValue(6);
label_4 = new QLabel(CLoraSettingsGui); label_4 = new QLabel(groupBox);
label_4->setObjectName(QString::fromUtf8("label_4")); label_4->setObjectName(QString::fromUtf8("label_4"));
label_4->setGeometry(QRect(270, 110, 71, 16)); label_4->setGeometry(QRect(200, 30, 71, 16));
checkBox = new QCheckBox(CLoraSettingsGui);
checkBox->setObjectName(QString::fromUtf8("checkBox"));
checkBox->setGeometry(QRect(70, 60, 281, 20));
retranslateUi(CLoraSettingsGui); retranslateUi(CLoraSettingsGui);
@ -121,6 +125,7 @@ public:
"Chaloupe = 8", nullptr)); "Chaloupe = 8", nullptr));
mUseLoraIFCheckBx->setText(QCoreApplication::translate("CLoraSettingsGui", "Use LoraInterface (restart needed)", nullptr)); mUseLoraIFCheckBx->setText(QCoreApplication::translate("CLoraSettingsGui", "Use LoraInterface (restart needed)", nullptr));
label_4->setText(QCoreApplication::translate("CLoraSettingsGui", "4", nullptr)); label_4->setText(QCoreApplication::translate("CLoraSettingsGui", "4", nullptr));
checkBox->setText(QCoreApplication::translate("CLoraSettingsGui", "Use LTE interface (restart needed)", nullptr));
} // retranslateUi } // retranslateUi
}; };