; httpdemo.vnm ; short demo of http server ; (A) 2010-07-27 ported to VM2 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 Print To http, "VM1 HTTP demo", CR Print To http, "", CR Print To http, "Hello
", CR Print To http, "your IP address is ", http.Address:"IP", "
", CR Print To http, t.Time, " milliseconds have elapsed since last request
", CR Print To http, "this page has been displayed ", counter, " times", "
", CR Print To http, "", CR t.Reset End