; 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(<<<HTML: <html><head><title>VM2 HTTP demo</title></head> <body> Hello<br> your IP Address Is %I<br> %u milliseconds have elapsed since last request<br> This page has been displayed %u times<br> </body></html> >>>, http.Address, t.Time, counter) t.Reset End