Why doesn't the HTML source apply?

I ran the source that implements webpage. By the way, the html source is normal, but it appears as follows. can i know the cause?

source

// The Geek Pub - Controlling an Arduino Pin from a WebPage
// Freely distributable with attribution and link to TheGeekPub.com

#include "SPI.h"
#include "Ethernet.h"

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xAD, 0xEE, 0xBE }; //physical mac address
byte ip[] = { 192, 168, 0, 248 }; // IP address in LAN – need to change according to your Network address
byte gateway[] = { 192, 168, 0, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(80); //server port

String controlString; // Captures out URI querystring;;
int blueLEDPin = 2; // pin where our blue LED is connected

void setup(){
pinMode(blueLEDPin, OUTPUT); // change pin 2 to OUTPUT pin
Serial.begin(115200);

// Initialize the Ethernet
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();
}

void loop(){
// Create a client connection
EthernetClient client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
//read the HTTP request
if (controlString.length() < 100) {

// write characters to string
controlString += c;
}

//if HTTP request has ended– 0x0D is Carriage Return \n ASCII
if (c == 0x0D) {
client.println("HTTP/1.1 200 OK"); //send new page
client.println("Content-Type: text/html");
client.println();

client.println("<html>");
client.println("<head>");
client.println("<title>The Geek Pub Arduino Ethernet Test Page</title>");
client.println("</head>");
client.println("<body>");
client.println("<img src="https://cdn.thegeekpub.com/wp-content/uploads/2018/01/the-geek-pub-big-logo-new.jpg\") style="width: 55%; margin-left: auto; margin-right: auto; display: block;" />");
client.println("<h1 style="color: blue; font-family: arial; text-align: center;">THE GEEK PUB ARDUINO ETHERNET TEST PAGE</h1>");
client.println("<h2 style="color: green; font-family: arial; text-align: center;">LED ON/OFF FROM WEBPAGE</h2>");
client.println("<hr>");
client.println("<h2 style="color: blue; font-family: arial; text-align: center;"><a href="/?GPLED2ON"">Turn On The Blue LED</a> - <a href="/?GPLED2OFF"">Turn Off the Blue LED</a></h2>");
client.println("</body>");
client.println("</html>");

delay(10);
//stopping client
client.stop();

// control arduino pin
if(controlString.indexOf("?GPLED2ON")) //checks for LEDON
{
digitalWrite(blueLEDPin, HIGH); // set pin high
}
else{
if(controlString.indexOf("?GPLED2OFF")) //checks for LEDOFF
{
digitalWrite(blueLEDPin, LOW); // set pin low
}
}
//clearing string for next read
controlString="";

}
}
}
}
}

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

Your topic was MOVED to its current forum category which is more appropriate than the original as it has nothing to do with Installation and Troubleshooting of the IDE

You have to escape all those quotes inside the HTML you are trying to use. You can not take a string that has quotes inside of it and simply put it inside a .println() surrounded by quotes

client.println("<img src=\"[The Geek Pub - Mak]...

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.