; httpdemo.vnm ; short demo of http server ; (A) 2014-07-27 changed to use embedded text in send_response procedure To init Make eth Ethernet Make http HTTPServer Make s String(100) Make t Stopwatch ; to generate some timing info for display counter := 0 End ; processes incoming HTTP requests To main Print "IP address ", eth:1, CR Print "http server running", CR t.Reset Forever [ http.Get(s) ; wait for a request Print "received request: ", s, CR If s.Compare("/") = 0 ; we only service requests for "/" [ counter := counter + 1 send_response ] http.Flush ; ] End ; response to root "GET /" request To send_response http.printf(<<VM2 HTTP demo Hello
your IP address is %I
%u milliseconds have elapsed since last request
this page has been displayed %u times
>>>, http.Address, t.Time, counter) t.Reset End