ESP01 connected to it.
The code that you posted would be used if you would use an ESP8266 standanlone.
Did you use chatGPT do get this code?
If yes read this to get explained why it does not work
An ESP8266-01 has a AT-firmware flashed into it when you buy it.
You would need to use a code on the arduino that is written for arduino-uno which communicates with the ESP8266-01 over a serial interface.
Big hassle to get connected using the AT-firmware.
It will be much easier to use a different ESP8266-board like a nodeMCU
or
even better to use an ESP32-nodeMCU standalone by eliminating the arduino uno.
The microocntroller-world is not super-standardised like USB-devices and Smartphone-Apps
You have to take care of more details than just
"Does the plug fit into the socket"?
best regards Stefan