; Minimal Web server using a local file system ; IP addresses: ; The VM2 obtains its IP address from a DHCP server on your LAN. ; This IP address is not guaranteed to stay the same from run to run. ; For real applications you may need to configure the DHCP server on your ; LAN to allocate a fixed IP address to the VM2. TO init Make fs filesystem("fla") Make eth Ethernet(nil, "vm2server") END TO main eth.Connect Print "Server running on IP Address ", eth.Address('i'):"IP", CR Repeat 4 Start server ; start four server tasks END TO server LOCAL http := New HTTPServer(fs) LOCAL path := New string(100) FOREVER [ http.get(path) ; if you need to process requests not matching an existing filename, ; the code to do so is inserted here. ; This example lists directories when uncommented ; if fs.find(path) = 2 ; ServeDirectory(http, "VM2 test", path) http.Flush ] END ; Optional code to list directories To ServeDirectory(http, title, dir) http.printf("%s: %s\n", title, dir) http.printf("

Directory of %s: %s

\n
", title, dir)
	print to http, fs:dir:"%z %Y-%m-%d %h:%M:%s %b %n"
	http.printf("
") End