37 lines
742 B
C++
37 lines
742 B
C++
#include <QCoreApplication>
|
|
#include <QDebug>
|
|
#include <QTcpServer>
|
|
#include <QHttpServer>
|
|
#include <memory>
|
|
|
|
#include "perfjson.h"
|
|
#include "fstop.h"
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
QCoreApplication app{argc, argv};
|
|
|
|
auto tcpServer = std::make_unique<QTcpServer>();
|
|
|
|
QHttpServer server;
|
|
|
|
if (!tcpServer->listen(QHostAddress::LocalHost, 8000))
|
|
{
|
|
qFatal("could not listen: %s", qPrintable(tcpServer->errorString()));
|
|
return -1;
|
|
}
|
|
|
|
if (!server.bind(tcpServer.get()))
|
|
{
|
|
qFatal("could not bind webserver to socket");
|
|
return -2;
|
|
}
|
|
|
|
tcpServer.release(); // QHttpServer now owns QTcpServer
|
|
|
|
PerfJson perfJson{server};
|
|
FsTop fsTop{server};
|
|
|
|
return app.exec();
|
|
}
|