Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Käppler
ampel-firmware
Commits
32cde90b
Commit
32cde90b
authored
Apr 17, 2021
by
Eric Duminil
Browse files
Basic webserver commands
parent
6e522d4e
Changes
1
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/web_server.cpp
View file @
32cde90b
...
...
@@ -22,6 +22,7 @@ namespace web_server {
const
char
*
script_template
;
void
handleWebServerRoot
();
void
handlePageNotFound
();
void
handleWebServerCommand
();
#ifdef AMPEL_CSV
void
handleDeleteCSV
();
...
...
@@ -173,6 +174,7 @@ namespace web_server {
// Web-server
http
.
on
(
"/"
,
handleWebServerRoot
);
http
.
on
(
"/command"
,
handleWebServerCommand
);
#ifdef AMPEL_CSV
http
.
on
(
"/"
+
csv_writer
::
filename
,
handleWebServerCSV
);
http
.
on
(
"/delete_csv"
,
HTTP_POST
,
handleDeleteCSV
);
...
...
@@ -275,6 +277,15 @@ namespace web_server {
}
#endif
void
handleWebServerCommand
()
{
if
(
!
shouldBeAllowed
())
{
return
http
.
requestAuthentication
(
DIGEST_AUTH
);
}
sensor_commands
::
run
(
http
.
arg
(
"send"
).
c_str
());
http
.
sendHeader
(
"Location"
,
"/"
);
http
.
send
(
303
);
}
void
handlePageNotFound
()
{
http
.
send
(
404
,
F
(
"text/plain"
),
F
(
"404: Not found"
));
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment