from one html (IP) to another html (IP)

hello, I need help to change the next code. the code Works but when I push the button i want to open another hmtl (another arduino IP). The first arduino I would like to use as a home website and if I push a button open another HTML (another arduino with another IP) and close home website. thanks

[//* 
   Copyright (c) 2017 Boot&Work Corp., S.L. All rights reserved

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
//If using V7 versions you have to include instead the following library: #include <Ethernet.h> 
 #include <Ethernet2.h>

#define TCP_PORT 80

// Digital output
int pin = Q0_0;
int value = LOW;
int _numDigitalOutputs = 1;

uint8_t _mac[] = {0xDE, 0xAB, 0xBE, 0x15, 0x00, 0x01};
byte IP[] = {192, 168, 1, 219};

EthernetServer _server(TCP_PORT);

////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
  Serial.begin(9600L);
  Serial.println("ISWeb started");

  pinMode(pin, OUTPUT);
  digitalWrite(pin, value);

  Ethernet.begin(_mac, IP);
  Serial.print("IP address: ");
  Serial.println(Ethernet.localIP());

  _server.begin();
  Serial.print("Listening on port ");
  Serial.println(TCP_PORT);
}

////////////////////////////////////////////////////////////////////////////////////////////////////
void loop() {
  EthernetClient client = _server.available();
  if (client) {
    String requestType = client.readStringUntil(' ');
    String requestUrl = client.readStringUntil(' ');
    String requestVersion = client.readStringUntil('\n');
    String response;
    if (requestType == "GET") {
      Serial.println("process GET");
      Serial.print("Request URL: ");
      Serial.println(requestUrl);
      if (requestUrl == "/") {
        response = createResponse();
      } else if (requestUrl.startsWith("/toggle")) {
        togglePin();
        response = createResponse();
      } else {
        response = create404();
      }
    } else {
      response = create404();
    }
    sendResponse(response, client);

    client.stop();
  }
}

////////////////////////////////////////////////////////////////////////////////////////////////////
String createResponse() {
  String content =
    "<!DOCTYPE html>"
    "<html>"
    "<head>"
    "<title>ISWeb</title>"
    "</head>"
    "<body>"
    "Arduino web server IS
";
    
  content += "Q0.0: <a href=\"/toggle\">";
  content += value == HIGH ? "HIGH" : "LOW"; // if value = HIGH print HIGH, else print LOW
  content += "</a>";
  
  content +=
    "</body>"
    "</html>";

  return createResponse(200, content);
}

////////////////////////////////////////////////////////////////////////////////////////////////////
String create404() {
  return createResponse(404, "404 Not Found");
}

////////////////////////////////////////////////////////////////////////////////////////////////////
String createResponse(int statusCode, const String &content) {
  String response;
  switch (statusCode) {
    case 200:
      response = "HTTP/1.1 200 OK\r\n";
      break;
    case 404:
      response = "HTTP/1.1 404 Not found\r\n";
      break;
    default:
      response = "HTTP/1.1 500 Internal server error\r\n";
      break;
  }

  response +=
    "Server: ISWeb\r\n"
    "Content-Type: text/html\r\n"
    "Connection: closed\r\n"
    "Content-Length: ";
  response.concat(content.length());
  response += "\r\n"
              "\r\n";
  response += content;
  return response;
}

////////////////////////////////////////////////////////////////////////////////////////////////////
void sendResponse(const String &response, EthernetClient &client) {
  client.print(response);
}

////////////////////////////////////////////////////////////////////////////////////////////////////
void togglePin() {
  if (value == HIGH) {
    value = LOW;
  }
  else {
    value = HIGH;
  }
  digitalWrite(pin, value);
}code]

hello, I need help to change the next code. the code Works but when I push the button i want to open another hmtl (another arduino IP). The first arduino I would like to use as a home website and if I push a button open another HTML (another arduino with another IP) and close home website. thanks

Do you understand how clients and servers work?

A client (web browser, for example) makes a GET request to a specific server. That server generates a response, and might also do something.

The code you posted has the Arduino acting as a server. The web browser asks it do to something. You can NOT have some other Arduino then serve up the response.

You COULD serve up a redirect response, telling the client to make another request from another site. But, how will you know which one it should make the new request to?

you could add a simple Link on Arduino1 which calls a page on Arduino2.

@noiasca that is what i want to do, how I can add a link?

@PaulS yes the problema is that I don't really understand how Works an arduino like a server or client...ill check it better

thankssss

I don't understand your question?!?

I've meant a hyperlink / href. The same like you used in

content += "Q0.0: <a href=\"/toggle\">";
  content += value == HIGH ? "HIGH" : "LOW"; // if value = HIGH print HIGH, else print LOW
  content += "</a>";

but not local on the arduino1 which act as your primary GUI but to a resource on your second arduino2

something like

content += "Q0.0: <a href=\"http://192.1.1.2/toggle\">";
  content += value == HIGH ? "HIGH" : "LOW"; // if value = HIGH print HIGH, else print LOW
  content += "</a>";

where 192.1.1.2 is the IP of your second Arduino2

(not a good example I know - but as it is from your code you hopefully understand what I mean)

imagine:
first arduino for home HTML 192.168.1.1
2 arduino: 192.168.1.2
3 arduino: 192.168.1.3
4 arduino: 192.168.1.4

So when I type 192.168.1.1 in my browser, it will open my first arduino. in this Hmtl website I would like to have 3 links. Each link connected for its arduino. so if I click in the 2 arduino link in home HTML it should open 2 arduino. If i click in 4 arduino, it should open 4 arduino HTML.

thanksssssss

as told in my post - you need a href on Arduino1 to the other Arduino4.

<a href='http://192.168.1.4/'>Arduino4</a>

Yes it´s true. Finally i did like you told me thanksssssssssssss

adnopbi, HTML is a display language suitable to take information and display it so that a user can interact with the UI. Look into RESTful Web API's. You could host that on an ESP8266 or Node MCU and accept data, in for example JSON format, and more easily communicate information between two devices. That information could then be displayed via HTML on the receiving web page for the user to interact with.

Typically you would write HTML to display something like a button. When the button is pressed, JavaScript running in the client browser would format an API call to a Web Server. This server could be another ESP8266 or Node MCU. The address would be something like
POST http:///controller/api/displaySomething
If you didn't want to learn JSON, you could extend that address to include:
?MyData=1&TurnOnLight=true&ReplyWithStatus=true

JSON is a format that would enable you to encode alot more, and potentially complicated data, images, or anything really. You'd have to learn about encoding of some of that data, but there are ways to transmit binary files, like PDF's, TIF, JPG images from a single command.

The receiving side would disassemble this information. and reply to the POST with any pertinent information. For example it might reply with the status of all of the devices you are controlling.

This is the tip of the ice berg. There is alot to learn to figure out how to implement what is stated above, but there are plenty of examples available to get you started.