45 {
47
49
50
51
52 webApp.get(
"/jalousien/:id", []
APPLICATION(req, res) {
53 VLOG(1) << "Param: " << req->param("id");
54 VLOG(1) << "Qurey: " << req->query("action");
55
56 std::string arguments =
"aircontrol -t " +
jalousien[req->param(
"id")] +
"_" +
actions[req->query(
"action")];
57
58 int ret = system(arguments.c_str());
59 ret = (ret >> 8) & 0xFF;
60
61
62
63
64
65
66 switch (ret) {
67 case 0:
68 res->status(200).send("OK: " + arguments);
69 break;
70 case 127:
71 res->status(404).send("ERROR not found: " + arguments);
72 break;
73 }
74 });
75
77 res->status(404).send("No Jalousie specified");
78 });
79
80 webApp.listen(8080,
83 switch (state) {
85 VLOG(1) << instanceName << ": listening on '" << socketAddress.toString() << "'";
86 break;
88 VLOG(1) << instanceName << ": disabled";
89 break;
91 LOG(ERROR) << instanceName << ": " << socketAddress.toString() << ": " << state.what();
92 break;
94 LOG(FATAL) << instanceName << ": " << socketAddress.toString() << ": " << state.what();
95 break;
96 }
97 });
98
100}
#define APPLICATION(req, res)
static constexpr int DISABLED
static constexpr int ERROR
static constexpr int FATAL
typename Server::SocketAddress SocketAddress
static void init(int argc, char *argv[])
static int start(const utils::Timeval &timeOut={LONG_MAX, 0})
static std::map< std::string, std::string > jalousien
static std::map< std::string, std::string > actions