How to respond conditionally based on the request when using netcat
问题 I am trying to set up a web server using only windows batch scripting. I have already come up with the following script: @echo off @setlocal enabledelayedexpansion for /l %%a in (1,0,2) do ( type tempfile.txt | nc -w 1 -l -p 80 | findstr mystring if !ERRORLEVEL! == 0 ( echo found > tempfile.txt ) else ( echo not-found > tempfile.txt ) ) However, the response is always one request behind, I mean, if I type something like this into the browser: REQUEST: localhost/mystring I will get the