• Stars
    star
    112
  • Rank 312,240 (Top 7 %)
  • Language
    Julia
  • License
    MIT License
  • Created over 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple development server with live-reload capability for Julia.

Live Server for Julia

CI Actions Status codecov docs

This is a simple and lightweight development web-server written in Julia, based on HTTP.jl. It has live-reload capability, i.e. when modifying a file, every browser (tab) currently displaying the corresponding page is automatically refreshed.

LiveServer is inspired from Python's http.server and Node's browsersync.

Installation

To install it in Julia ≥ 1.6, use the package manager with

pkg> add LiveServer

Broken pipe message

Infrequently, you may see an error message in your console while using LiveServer that does not interrupt the server and does not otherwise affect your ability to see updates in the browser. This error message will look like

┌ LogLevel(1999): handle_connection handler error
│   exception =
│    IOError: write: broken pipe (EPIPE)

You can basically ignore this message, it's a problem with HTTP.jl.

If your application depends on LiveServer and you'd like to avoid having that kind of messages being shown to your users, you can consider using LoggingExtras.jl which allows you to filter out messages based on their provenance.

We experimented with shipping LoggingExtras in LiveServer but ended up rolling that back as it made other applications less stable.

Legacy notes

For Julia < 1.6, you can use LiveServer's version 0.9.2:

For Julia [1.0, 1.3), you can use LiveServer's version 0.7.4:

Make it a shell command

LiveServer is a small package and fast to load with one main functionality (serve), it can be convenient to make it a shell command: (I'm using the name lss here but you could use something else):

alias lss='julia -e "import LiveServer as LS; LS.serve(launch_browser=true)"'

you can then use lss in any directory to show a directory listing in your browser, and if the directory has an index.html then that will be rendered in your browser.

Usage

The main function LiveServer exports is serve which starts listening to the current folder and makes its content available to a browser. 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.

In the REPL:

julia> using LiveServer
julia> serve(host="0.0.0.0", port=8001, dir=".") # starts the remote server & the file watching
✓ LiveServer listening on http://0.0.0.0:8001...
  (use CTRL+C to shut down)

In the terminal:

julia -e 'using LiveServer; serve(host="0.0.0.0", port=8001, dir=".")'

Open a browser and go to https://localhost:8001/ to see the rendered content of index.html or, if it doesn't exist, the content of the directory. You can set the port to a custom number. This is similar to the http.server in Python.

Serve docs

servedocs is a convenience function that runs Documenter along with LiveServer to watch your doc files for any changes and render them in your browser when modifications are detected.

Assuming you are in directory/to/YourPackage.jl, that you have a docs/ folder as prescribed by Documenter.jl and LiveServer installed in your global environment, you can run:

$ julia

pkg> activate docs

julia> using YourPackage, LiveServer

julia> servedocs()
[ Info: SetupBuildDirectory: setting up build directory.
[ Info: ExpandTemplates: expanding markdown templates.
...
└ Deploying: ✘
✓ LiveServer listening on http://localhost:8000/ ...
  (use CTRL+C to shut down)

Open a browser and go to http://localhost:8000/ to see your docs being rendered; try modifying files (e.g. docs/index.md) and watch the changes being rendered in the browser.

To run the server with one line of code, run:

$ julia --project=docs -ie 'using YourPackage, LiveServer; servedocs()'

Note: this works with Literate.jl as well. See the docs.

DEV/Path testing

See also issue #135 and related PRs.

  • servedocs(), navigate to literate, images should show
  • serve() navigate manually to docs/build/ should show, remove trailing slash in URL docs/build should redirect to docs/build/
  • serve(dir=...) should work + when navigating to assets etc

More Repositories

1

Franklin.jl

(yet another) static site generator. Simple, customisable, fast, maths with KaTeX, code evaluation, optional pre-rendering, in Julia.
Julia
853
star
2

PkgPage.jl

Create a beautiful landing page for your package in less than 10 minutes.
CSS
116
star
3

FranklinTemplates.jl

Simple website templates for Franklin.jl
CSS
70
star
4

Xranklin.jl

Experimental repo for a refactoring of Franklin.jl
Julia
39
star
5

JSXGraph.jl

[wip] Julia bridge to JSXGraph for interactive plots
HTML
16
star
6

EPBP

Expectation Particle Belief Propagation code
Julia
11
star
7

GPlot.jl

[WIP] Fast 2D-3D publication-quality plotting with LaTeX support in Julia via the Graphics Layout Engine
Julia
10
star
8

ft-academic-resume

draft Franklin template for the academic template
Julia
10
star
9

tlienart.github.io

Code for my website, powered by Franklin.jl
JavaScript
9
star
10

AnalyticalEngine.jl

[draft] Agnostic Machine Learning models working on CPUs, GPUs, distributed architecture, etc.
Julia
6
star
11

tex2jem

Convert a .tex file into Jem-style (simple markdown) HTML
Python
5
star
12

ExpFamily.jl

A package to handle Exponential Family distributions
Julia
5
star
13

SMC.jl

Sequential Monte Carlo methods in Julia (experimental)
Julia
4
star
14

PlusPlus.jl

++ as array vcat and string concat
Julia
4
star
15

EPInference.jl

A package to perform EP inference in a variety of settings
Julia
4
star
16

franklindocs

Website for Franklin.jl
HTML
4
star
17

coder-xranklin-demo

JavaScript
2
star
18

Tutorialist.jl

[draft] create a website for tutorials; worry about the content not the layout
HTML
2
star
19

SimpleParser.jl

A (really) simple parser in Julia (edit: all that's in there has been integrated into Franklin.jl)
Julia
2
star
20

FranklinUtils.jl

Barebones utility package to help with writing lx functions or h functions with Franklin.jl
Julia
2
star
21

DistillTemplate

[wip] Port of the distill template to Franklin
JavaScript
2
star
22

TuringLearnDraft.jl

Julia
1
star
23

demo-soilwater.jl

Julia
1
star
24

papers

[ongoing] a list of (good) papers that I've read and may want to refer back to
1
star
25

ft-forty

CSS
1
star
26

demoplotsgallery

JavaScript
1
star
27

FranklinPluginExample.jl

Julia
1
star
28

JuDocExample

HTML
1
star
29

ftest

CSS
1
star
30

fred

CSS
1
star
31

smsetup

Rough scripts to setup a sagemaker notebook
Julia
1
star
32

FranklinFAQ

FAQ/demos for Franklin
CSS
1
star
33

julia-blog-migration

translation of some julia blog posts in JuDoc
HTML
1
star
34

booksjl-franklin

JavaScript
1
star
35

julia-site

Copy of https://julialang.org/ using Franklin.jl (WIP POC)
Jupyter Notebook
1
star
36

ConstrainedPDMP

Notebook to reproduce the results presented in the paper "PDMP for Scalable Monte Carlo on Restricted Domains"
Jupyter Notebook
1
star
37

juliagpu

migration of the juliagpu website to franklin
JavaScript
1
star
38

cppds

CSS
1
star