You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
938 B
49 lines
938 B
|
2 years ago
|
|
||
|
|
#include <ESP8266WebServer.h>
|
||
|
|
#include <WiFiClient.h>
|
||
|
|
#include <ESP8266WiFi.h>
|
||
|
|
|
||
|
|
const char* ssid = "mathematics";
|
||
|
|
const char* password = "fzbyj8r7pdEk";
|
||
|
|
|
||
|
|
ESP8266WebServer server(7000);
|
||
|
|
|
||
|
|
String page = "";
|
||
|
|
String txt = "";
|
||
|
|
|
||
|
|
void setup() {
|
||
|
|
|
||
|
|
delay(1000);
|
||
|
|
Serial.begin(115200);
|
||
|
|
WiFi.begin(ssid, password);
|
||
|
|
Serial.println("");
|
||
|
|
|
||
|
|
// wait for connection
|
||
|
|
while (WiFi.status() != WL_CONNECTED) {
|
||
|
|
delay(500);
|
||
|
|
Serial.print(".");
|
||
|
|
}
|
||
|
|
Serial.print("connected to ");
|
||
|
|
Serial.println(ssid);
|
||
|
|
Serial.print("ip: ");
|
||
|
|
Serial.println(WiFi.localIP());
|
||
|
|
server.on("/", []() {
|
||
|
|
page = "<h1>hi</h1>" + String(txt) + 1;
|
||
|
|
server.send(200, "text/html", page);
|
||
|
|
});
|
||
|
|
|
||
|
|
server.begin();
|
||
|
|
Serial.println("started");
|
||
|
|
}
|
||
|
|
|
||
|
|
void loop() {
|
||
|
|
if (Serial.available() > 0) {
|
||
|
|
String txt = Serial.readStringUntil('\n');
|
||
|
|
Serial.println(txt);
|
||
|
|
Serial.println(page);
|
||
|
|
}
|
||
|
|
|
||
|
|
server.handleClient();
|
||
|
|
// Serial.println("ip: ");
|
||
|
|
|
||
|
|
}
|