2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
42#include "express/legacy/in/WebApp.h"
43#include "express/middleware/VerboseRequest.h"
44#include "express/tls/in/WebApp.h"
46#ifndef DOXYGEN_SHOULD_SKIP_THIS
48#include "log/Logger.h"
52int main(
int argc,
char* argv[]) {
55 using LegacyWebApp = express::legacy::
in::WebApp;
56 using LegacySocketAddress = LegacyWebApp::SocketAddress;
58 const LegacyWebApp legacyApp
("legacy");
61 legacyApp.use(express::
middleware::VerboseRequest());
70 " background-image: repeating-radial-gradient( circle at 0 0, #fff, #ddd 50px);"
72 " input[type=\"file\"] {"
76 " border: 1px dotted;"
81 " <h1>File-Upload with input type=\"file\"</h1>"
83 " <h2>Send us something fancy!</h2>"
84 " <form method=\"post\" enctype=\"multipart/form-data\">"
85 " <label> Select a text file (*.txt, *.html etc.) from your computer."
86 " <input name=\"datei\" type=\"file\" size=\"50\" accept=\"text/*\">"
88 " <button>… and off we go!</button>"
98 " <h1>Thank you, we received your file!</h1>\n"
99 " <h2>Content:</h2>\n"
101 std::string(req->
body.begin(), req->
body.end()) +
107 legacyApp
.listen(8080
, [](
const LegacySocketAddress& socketAddress,
const core::socket::
State& state) {
110 VLOG(1) <<
"legacyApp: listening on '" << socketAddress
.toString() <<
"'";
113 VLOG(1) <<
"legacyApp: disabled";
116 VLOG(1) <<
"legacyApp: error occurred";
119 VLOG(1) <<
"legacyApp: fatal error occurred";
124 using TLSWebApp = express::tls::
in::WebApp;
125 using TLSSocketAddress = TLSWebApp::SocketAddress;
127 const TLSWebApp tlsApp
("tls");
131 .setCert("/home/voc/projects/snodec/snode.c/certs/wildcard.home.vchrist.at_-_snode.c_-_server.pem")
132 .setCertKey("/home/voc/projects/snodec/snode.c/certs/Volker_Christian_-_Web_-_snode.c_-_server.key.encrypted.pem")
135 tlsApp.use(legacyApp);
137 tlsApp
.listen("localhost", 8088
, [](
const TLSSocketAddress& socketAddress,
const core::socket::
State& state) {
140 VLOG(1) <<
"tlsApp: listening on '" << socketAddress
.toString() <<
"'";
143 VLOG(1) <<
"tlsApp: disabled";
146 VLOG(1) <<
"tlsApp: error occurred";
149 VLOG(1) <<
"tlsApp: fatal error occurred";
#define APPLICATION(req, res)
Config & getConfig() const
static constexpr int DISABLED
static constexpr int ERROR
static constexpr int FATAL
void send(const std::string &chunk)
WebAppT(const std::string &name)
static void init(int argc, char *argv[])
static int start(const utils::Timeval &timeOut={LONG_MAX, 0})
ConfigTls & setCert(const std::string &cert)
ConfigTls & setCertKey(const std::string &certKey)
ConfigTls & setCertKeyPassword(const std::string &certKeyPassword)
std::string toString(bool expanded=true) const override
const Super & listen(uint16_t port, const std::function< void(const SocketAddress &, core::socket::State)> &onStatus) const
const Super & listen(const std::string &ipOrHostname, uint16_t port, const std::function< void(const SocketAddress &, core::socket::State)> &onStatus) const
ConfigSocketServer & setReuseAddress(bool reuseAddress=true)
int main(int argc, char *argv[])