-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfigWebServer.h
57 lines (46 loc) · 1.32 KB
/
ConfigWebServer.h
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
50
51
52
53
54
55
56
57
#ifndef _CONFIGWEBSERVER_H
#define _CONFIGWEBSERVER_H
#include <WiFi.h>
#include <DNSServer.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
const char index_html[] PROGMEM = R"rawliteral(
<!DOCTYPE HTML><html><head>
<title>CryptoCore</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head><body>
<h3>TOTP</h3>
<br><br>
<form action="/get">
<input id="timestamp" type="text" name="timestamp" value="">
<input type="submit" value="Submit">
</form>
<script>
function setTimestamp() {
document.getElementById('timestamp').value = Math.floor(new Date().getTime()/1000);
}
setInterval(setTimestamp, 1000);
setTimestamp();
</script>
</body></html>)rawliteral";
typedef class CaptiveRequestHandler : public AsyncWebHandler {
public:
CaptiveRequestHandler() {}
virtual ~CaptiveRequestHandler() {}
bool canHandle(AsyncWebServerRequest *request){
//request->addInterestingHeader("ANY");
return true;
}
void handleRequest(AsyncWebServerRequest *request) {
request->send_P(200, "text/html", index_html);
}
} CaptiveRequestHandler;
typedef class ConfigWebServer {
public:
ConfigWebServer();
void init(DNSServer);
void start(AsyncWebServer, CaptiveRequestHandler*);
void update(DNSServer);
private:
} ConfigWebServer;
#endif