NodeMCU run sensor code while listening for wifi input?
The problem is that at

while (!client.available()) {
  delay(1);
}
// your wifi code


you wait for a wifi event and in that time you obviously can't read the sensor. Just poll for incoming requests by doing it like

if (client.available()) {
  // your wifi code
}


This way your loop skips the wifi-routine if there is nothing to do and proceeds with reading the sensor.

As mikrocontrollers usually don't run a OS, you don't have multitasking which you have to implement yourself.
Generally you have to avoid using delay loops when you want several tasks being executed "parallely".