diff --git a/README.md b/README.md index b81bab4..5f93f83 100644 --- a/README.md +++ b/README.md @@ -194,7 +194,7 @@ nix-shell --run 'ghcid -T ":main serve"' simply run `ghcid -T ":main serve"` instead of the above command if you do not wish to use Nix.) -Running this command gives you a local HTTP server at http://localhost:8080/ +Running this command gives you a local HTTP server at http://127.0.0.1:8080/ (serving the generated files) that automatically reloads when either the content (`content/`) or the HTML/CSS/build-actions (`Main.hs`) changes. Hot reload, in other words. @@ -219,7 +219,7 @@ installed. The "serve" subcommand will run the Shake build action passed as argument on every file change and spin up a HTTP server. -Run that command, and visit http://localhost:8080 to view your site. +Run that command, and visit http://127.0.0.1:8080 to view your site. ### Editing workflow diff --git a/src/Rib/Server.hs b/src/Rib/Server.hs index 24e8e23..19b996a 100644 --- a/src/Rib/Server.hs +++ b/src/Rib/Server.hs @@ -22,6 +22,8 @@ staticSiteServerSettings root = defaultSettings = defaultFileServerSettings root -- | Run a HTTP server to serve a directory of static files +-- +-- Binds the server to host 127.0.0.1. serve :: -- | Port number to bind to Int -> @@ -29,12 +31,12 @@ serve :: FilePath -> IO () serve port path = do - putStrLn $ "[Rib] Serving at http://" <> show host <> ":" <> show port + putStrLn $ "[Rib] Serving " <> path <> " at http://" <> host <> ":" <> show port Warp.runSettings settings app where app = staticApp $ staticSiteServerSettings path host = "127.0.0.1" settings = - Warp.setHost host + Warp.setHost (fromString host) $ Warp.setPort port $ Warp.defaultSettings