Put 2 codes together! (School project)

Yes i have tried that. But i think this while loop from the wifi does that the clap would not be detected if i put it in the same loop as clapper loop..

WiFiClient client = server.available();
if (!client) {
return;
}
while (!client.available()) {
delay(1);
}
rest.handle(client);