-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint.ino
45 lines (36 loc) · 1.19 KB
/
print.ino
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
// Inclusão das bibliotecas
#include <WiFi.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
// Instanciação do objeto da classe AsyncWebServer
AsyncWebServer server(80);
// Constantes das credenciais do WiFi
const char* ssid = "<SSID>";
const char* password = "<SENHA>";
void setup() {
// Conecta-se ao Ponto de acesso com as credenciais fornecidas
WiFi.begin(ssid, password);
Serial.begin(115200);
// disponibiliza o url "/"
server.on("/", HTTP_GET, [](AsyncWebServerRequest* request) {
AsyncResponseStream* response = request->beginResponseStream("text/html");
response->print("<html>");
response->print("<head> ");
response->print("<meta charset='utf-8'/>");
response->print("</head>");
response->print("<body>");
response->print("<h1>");
response->printf("Olá %s",request->client()->remoteIP().toString().c_str());
response->print("</h1>");
response->print("<p>");
response->print("Parágrafo aqui.");
response->print("</p>");
response->print("</body>");
response->print("<html>");
//envie a resposta por último
request->send(response);
});
// Servidor começa à ouvir os clientes
server.begin();
}
void loop() {}