Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ESP8266 (NodeMCU) - webserver - handling Root connections
- //Author: Martin Chlebovec
- //Web: https://arduino.php5.sk?lang=en
- //Donate: https://paypal.me/chlebovec
- //Date: 9. Feb. 2020
- #include <ESP8266WiFi.h>
- #include <ESP8266WebServer.h>
- const char *ssid = "MY_WIFI";
- const char *password = "MY_PASSWORD";
- ESP8266WebServer server(80);
- void handleRoot() {
- String response;
- response = "<!DOCTYPE html>\n";
- response += "<html>\n";
- response += "<head>\n";
- response += "<link rel=\"stylesheet\" type=\"text/css\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css\">\n";
- response += "<style>\n";
- response += "body {background-color: #F5B041;}\n";
- response += "</style>\n";
- response += "<title>Login V16</title>\n";
- response += "</head>\n";
- response += "<body>\n";
- response += "<center><button type=\"button\" class=\"btn btn-success\">OLA</button></center>\n";
- response += "</body>\n";
- response += "</html>";
- server.send(200, "text/html", response);
- }
- void setup() {
- Serial.begin(115200);
- delay(1000);
- WiFi.mode(WIFI_STA);
- WiFi.begin(ssid, password);
- Serial.println("");
- while (WiFi.status() != WL_CONNECTED) {
- delay(500);
- Serial.println(".");
- }
- Serial.print("IP address: ");
- Serial.println(WiFi.localIP());
- server.on("/", handleRoot);
- server.begin();
- }
- void loop() {
- while (WiFi.status() != WL_CONNECTED) {
- delay(500);
- Serial.println(".");
- }
- server.handleClient();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement