#live-reload #local-server #web-server #server #live #reload #web

bin+lib live-server

Launch a local network server with live reload feature for static pages

15 releases (8 breaking)

0.9.0 Nov 4, 2024
0.7.0 Dec 23, 2023
0.6.2 Oct 24, 2023
0.6.0 Mar 1, 2023
0.3.0 Mar 12, 2022

#299 in HTTP server

Download history 108/week @ 2024-08-05 33/week @ 2024-08-12 2/week @ 2024-08-19 3/week @ 2024-08-26 15/week @ 2024-09-16 37/week @ 2024-09-23 7/week @ 2024-09-30 8/week @ 2024-10-07 4/week @ 2024-10-14 142/week @ 2024-11-04 13/week @ 2024-11-11

156 downloads per month
Used in docki

MIT license

28KB
574 lines

crate-badge License check-badge

Live Server

Launch a local network server with live reload feature for static pages.

Binary

You can use it as a CLI program.

Install

$ cargo install live-server

Usage

$ live-server --help
Launch a local network server with live reload feature for static pages

Usage: live-server [OPTIONS] [ROOT]

Arguments:
  [ROOT]  Set the root path of the static assets [default: .]

Options:
      --index          Whether to show directory listings if there is no index.html
  -H, --host <HOST>    Set the listener host [default: 0.0.0.0]
  -p, --port <PORT>    Set the listener port [default: 0]
  -o, --open [<PAGE>]  Open the page in browser automatically
      --hard           Hard reload the page on update instead of hot reload
  -h, --help           Print help (see more with '--help')
  -V, --version        Print version
$ live-server
[2023-12-22T15:16:04Z INFO  live_server::server] Listening on http://10.17.95.220:6634/
[2023-12-22T15:16:04Z INFO  live_server::watcher] Listening on /home/mirus/html-demo

Log Level

You can set different RUST_LOG environment variable to filter the log. The default log level is info.

Package

You can also import it as a library in your project.

Create live server

use live_server::listen;

listen("127.0.0.1:8080", "./").await?.start().await?;

Enable logs (Optional)

env_logger::init();

Dependencies

~12–23MB
~316K SLoC