1
1
mirror of https://github.com/srid/rib.git synced 2024-11-27 01:12:09 +03:00

Also log the http root

This commit is contained in:
Sridhar Ratnakumar 2020-03-22 11:45:21 -04:00
parent 7e324b9777
commit 869125bd4f
2 changed files with 6 additions and 4 deletions

View File

@ -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

View File

@ -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