blob: 0699cbc1f746fd8fb9e60a070522730291d2ef8b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#define _POSIX_C_SOURCE 200809L
#include "endpoints.h"
#include "defs.h"
#include <libweb/http.h>
#define LOGIN_BODY \
"<header>\n" \
" <a href=\"" PROJECT_URL "\">" PROJECT_NAME "</a>, " \
PROJECT_DESC "\n" \
"</header>\n" \
" <form class=\"loginform\" action=\"/login\" method=\"post\">\n" \
" <label for=\"username\">Username:</label>\n" \
" <input type=\"text\" class=\"form-control\"\n" \
" id=\"username\" name=\"username\" autofocus><br>\n" \
" <label for=\"username\">Password:</label>\n" \
" <input type=\"password\" class=\"form-control\" \n" \
" id=\"password\" name=\"password\"><br>\n" \
" <input type=\"submit\" value=\"Submit\">\n" \
" </form>\n"
int ep_login_get(const struct http_payload *const p,
struct http_response *const r, void *const user)
{
static const char body[] =
DOCTYPE_TAG
"<html>\n"
" <head>\n"
" " STYLE_A "\n"
" " COMMON_HEAD "\n"
" </head>\n"
" " LOGIN_BODY "\n"
"</html>\n";
*r = (const struct http_response)
{
.status = HTTP_STATUS_OK,
.buf.ro = body,
.n = sizeof body - 1
};
if (http_response_add_header(r, "Content-Type", "text/html"))
{
fprintf(stderr, "%s: http_response_add_header failed\n", __func__);
return -1;
}
return 0;
}
|