how to change esp8266WiFi commands to esp8266webserver commands?

Hi everyone, I am new to IoT world and have almost zero knowledge of website side. I want upload image of local server and integrate it with my old code. I got SPIFFS part from here. I do get the point that if (server.streamFile(dataFile, dataType) != dataFile.size()) is responsible for showing data on page. But I want to add

if (dp == 10 and check2 == 0){
    html_3 = "<h2><meta http-equiv='refresh' content='1'></h2><h3>Data:</h3> <h4>"+data+"</h4>";}
    else {html_3 = "<h2><meta http-equiv='refresh' content='1'></h2><h3>Data:</h3> <h4>"+data+"</h4><h4>Your basket is being stolen!</h4>";
    html_4 = "<img src="\bin.jpg" alt="Image from ESP8266" width="200" height="200">";

lines in the SPIFFS code. So can someone help me how to do this?

Whatever is in SPIFFS is a file, it does not include code that is being compiled for/evaluated by the arduino. Here it seems you want two different files content being sent depending on a couple variables that are living in Arduino programming side.

You could consider having two files in SPIFFS and stream the right one based on your test or send the file in two parts, one from arduino code and then stream the content of the file in SPIFFS