1
|
#include <Wt/WApplication.h>
|
2
|
#include <Wt/WBootstrap5Theme.h>
|
3
|
#include <Wt/WServer.h>
|
4
|
|
5
|
#include <Wt/WContainerWidget.h>
|
6
|
#include <Wt/WVBoxLayout.h>
|
7
|
#include <Wt/WTextArea.h>
|
8
|
|
9
|
|
10
|
using namespace Wt;
|
11
|
|
12
|
|
13
|
|
14
|
// -----------------------------------------------------------------------------------
|
15
|
std::unique_ptr<WApplication> createHelloApplication(const WEnvironment &env)
|
16
|
{
|
17
|
auto app = std::make_unique<Wt::WApplication>(env);
|
18
|
|
19
|
auto theme = std::make_shared<Wt::WBootstrap5Theme>();
|
20
|
app->setTheme(theme);
|
21
|
|
22
|
auto mainVLayout = app->root()->setLayout(std::make_unique<WVBoxLayout>());
|
23
|
|
24
|
auto ta = mainVLayout->addWidget(std::make_unique<WTextArea>(), 1);
|
25
|
|
26
|
WString longText;
|
27
|
|
28
|
for (int i = 0; i < 300; i++)
|
29
|
longText += "Line " + std::to_string(i) + "\n";
|
30
|
|
31
|
ta->setText(longText);
|
32
|
|
33
|
return app;
|
34
|
}
|
35
|
|
36
|
|
37
|
// -----------------------------------------------------------------------------------
|
38
|
int main(int argc, char *argv[])
|
39
|
{
|
40
|
try
|
41
|
{
|
42
|
WServer server(argc, argv, WTHTTP_CONFIGURATION);
|
43
|
|
44
|
server.addEntryPoint(EntryPointType::Application,
|
45
|
std::bind(&createHelloApplication, std::placeholders::_1));
|
46
|
|
47
|
if (server.start())
|
48
|
{
|
49
|
int sig = WServer::waitForShutdown();
|
50
|
|
51
|
std::cerr << "*** Shutdown (signal = " << sig << ")" << std::endl;
|
52
|
server.stop();
|
53
|
|
54
|
if (sig == 1) // SIGHUP
|
55
|
WServer::restart(argc, argv, environ);
|
56
|
|
57
|
return 0;
|
58
|
}
|
59
|
}
|
60
|
catch (WServer::Exception &e)
|
61
|
{
|
62
|
std::cerr << "*** Server Exception: " << e.what() << std::endl;
|
63
|
}
|
64
|
catch (std::exception &e)
|
65
|
{
|
66
|
std::cerr << "*** Std Exception: " << e.what() << std::endl;
|
67
|
}
|
68
|
}
|