The function does not work in ESP8266

Good catch!

@arduino556665
Because of these lines:

your blinking function is never called after receiving a command from the client.
And there are more problems in your sketch:
This:

  String request = client.readStringUntil('/r');

should be

  String request = client.readStringUntil('\r');

And this:

  if (request.indexOf("/On") != -1) {
    flag = !flag;
  }
  else if (request.indexOf("/Off") != -1) {
    digitalWrite(R1, LOW);
  }

should be

  if (request.indexOf("/On") != -1) {
    flag = true;
  }
  else if (request.indexOf("/Off") != -1) {
    digitalWrite(R1, LOW);
    flag = false;
  }

Otherwise you will not be able to switch the blinking off with /Off