Hi everyone, we (@tlienart and myself) have developed a simple and lightweight pure-Julia development web-server, inspired from Python’s http.server
and Node’s browsersync
. It is based on HTTP.jl and has live-reload capability, i.e. when changing files, every browser (tab) currently displaying a corresponding page is automatically refreshed.
It is tested for Linux/Mac and Windows and Julia 1.0, 1.1, and nightly. It is in the General registry, i.e. you can install it by
pkg> add LiveServer
Functionality
The main function LiveServer
exports is serve
which starts observing the current (or specified) folder and serves its contents. The following code creates an example directory and serves it:
julia> using LiveServer
julia> LiveServer.example() # creates an "example/" folder with some files
julia> cd("example")
julia> serve() # starts the local server & the file watching
✓ LiveServer listening on http://localhost:8000/ ...
(use CTRL+C to shut down)
Open a Browser and go to http://localhost:8000/
to see the content being rendered; try modifying files (e.g. index.html
) and watch the changes being rendered immediately in the browser.
Note: This package in no way is, nor tries to be or become a production server. It is meant for developing static sites, let you efficiently work on your docs (see below), or anything else that requires a mock file-server with auto-reload of the browser.
Serve docs
Derived from serve
, servedocs
runs Documenter.jl along with LiveServer
to render your docs and will track and live-reload any modifications. Assuming you are in directory/to/YourPackage.jl
and that you have a docs/
folder as prescribed by Documenter
, just run:
julia> using LiveServer
julia> servedocs()
Go to http://localhost:8000/
to see your docs; try modifying files (e.g. docs/index.md
) and watch the changes being rendered in the browser.
Status
The main functionality works flawlessly and has been tested thoroughly (… but only by two people so far). There’s also a complete set of tests; the coverage is currently at 81% since we have to monkey-patch HTTP.jl
to fix #405 by PR #406 – the guys are working on a “clean” solution, and we will remove our “hacky” patch as soon as it is cleanly fixed.
We put quite some effort in having good documentation.
We welcome comments and suggestions for improvements!