Search code examples
htmlcesp8266arduino-idearduino-esp8266

ESP8266 html page code integrated into .ino file


I'm using an ESP8266 and this is the HTML part of the program. I copy and pasted from the depths of the internet and want to change the HTML page of the file. In what format can I add html code? Thanks! (I was trying to put a text-input field in but I want to put many HTML elements in later).

const String HtmlHtml = "<html><head>" 
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" /></head>";`
const String HtmlHtmlClose = "</html>";
const String HtmlTitle = "<h1>Arduino-er: ESP8266 AP WebServer exercise</h1><br/>\n";
const String HtmlLedStateLow = "<big>LED is now <b>ON</b></big><br/>\n";
const String HtmlLedStateHigh = "<big>LED is now <b>OFF</b></big><br/>\n";
const String HtmlButtons = 
"<a href=\"LEDOn\"><button style=\"display: block; width: 100%;\">ON</button></a><br/>" 
"<a href=\"LEDOff\"><button style=\"display: block; width: 100%;\">OFF</button></a><br/>";

Solution

  • I assume that you later have part where you combine your variables and make one big that you use to dispalay html. You can do something like this.

    -Open your editor and copy/paste code from your post

    -Edit it as you want

    -Delete variables in code that you posted and replace with one, example

      const String wholePage = "INSERT YOUR HTML";
    

    -And than on line where you added variables before just use your new where is whole HTML code

    Hope it helps! :)