/* * Example: Simple HTTP server using stdlib net/http_server * * Run: * $ fun examples/blocking/net/http.fun * * It will serve files from the ./web directory on http://127.0.0.1:8080 * * Test with curl in another terminal: * $ curl -v http://127.0.0.1:8080/ * $ curl -v http://127.0.0.1:8080/index.html * * You can also place a .fun script in ./web (e.g. hello.fun) and call it: * $ curl -v 'http://127.0.0.1:8080/hello.fun?name=Fun' */ #include // Configure PORT = 8080 DOC_ROOT = "./examples/data/htdocs/" print("Starting simple HTTP server example…") print("Serving '" + DOC_ROOT + "' on http://127.0.0.1:" + to_string(PORT)) print("Press Ctrl+C to stop.") srv = HTTPServer(PORT) srv.set_htdocs(DOC_ROOT) // Start (blocking loop) srv.start()