NodeMCU run sensor code while listening for wifi input? Is it possible to have code running while also listening for local inputs via ip address? I thought it would go in the 'while' portion but I presume that only responses when the ip is loaded.

void loop() {

  WiFiClient client = server.available();
  if (!client) {
    return;
  }
  while (!client.available()) {
    delay(1);   
  }
  String query = client.readStringUntil('\r');
  client.flush();

  if (query.indexOf("/open") != -1)  {
    open_fast();
  } else if (query.indexOf("/close") != -1)  {
    close_fast();
  }

  sensor = analogRead(A0);
  sensor = map(sensor, 0, 1023, 0, full);

  Serial.print(sensor);
  Serial.print("  ");
  Serial.println(pos);

  if (sensor &gt; pos) {
    open_slow();
    delay(1000);
  } else if (sensor &lt; pos) {
    close_slow();
    delay(1000);
  }
  delay(100);

}
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".