You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/index.md
+21-25Lines changed: 21 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ LiveServer is inspired from Python's [`http.server`](https://docs.python.org/3/l
7
7
8
8
## Installation
9
9
10
-
In Julia ≥ 1.0, you can add it using the Package Manager writing
10
+
In Julia ≥ 1.0, you can add it using the Package Manager with
11
11
12
12
```julia-repl
13
13
pkg> add LiveServer
@@ -67,35 +67,31 @@ Let's assume you have a directory similar to that generated by [`LiveServer.exam
67
67
└── blah.html
68
68
```
69
69
70
-
Calling `serve()` from within this directory starts a file server. It serves
71
-
the contents of the directory as a static site, with the folder structure
72
-
defining the paths of the URLs. That is, the file `blah.html` can be viewed
73
-
at `/pages/blah.html`. When a directory is specified instead of a file,
74
-
the server checks whether there is a file `index.html` in this directory and
75
-
serves it if available.
70
+
Calling `serve()` from within this directory starts a file server.
71
+
It serves the contents of the directory as a static site, with the folder structure defining the paths of the URLs.
72
+
That is, the file `blah.html` can be viewed at `/pages/blah.html`.
73
+
When a directory is specified instead of a file, the server checks whether there is a file `index.html` in this directory and serves it if available.
76
74
77
75
Visiting `http://localhost:8000/` makes your browser send a standard HTTP `GET`
78
-
request to the server. The server, running a listener loop, receives this
79
-
request, looks for `index.html` in the root
80
-
folder, and serves it. After serving it, `LiveServer` adds this file to the
81
-
list of watched files. That is, whenever this file changes, a callback is
82
-
fired (see below). The HTML page may also contain references to style sheets or
83
-
pictures, which are then requested by your browser as well. The server
84
-
sends them to the browser, and also adds them to the list of watched
85
-
files.
86
-
87
-
**But what about the live reloading?** Triggering a page refresh in the browser
88
-
is achieved by a WebSocket connection. The WebSocket API, according to
89
-
[MDN](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API), is
76
+
request to the server.
77
+
The server, running a listener loop, receives this request, looks for `index.html` in the root folder, and serves it.
78
+
After serving it, `LiveServer` adds this file to the list of watched files.
79
+
That is, whenever this file changes, a callback is fired (see below).
80
+
The HTML page may also contain references to style sheets or pictures, which are then requested by your browser as well.
81
+
The server sends them to the browser, and also adds them to the list of watched files.
82
+
83
+
#### But what about the live reloading?
84
+
85
+
Triggering a page refresh in the browser is achieved by a WebSocket connection.
86
+
The WebSocket API, according to [MDN](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API), is
87
+
90
88
> an advanced technology that makes it possible to open a two-way interactive
91
89
> communication session between the user's browser and a server.
92
90
`LiveServer` injects a small piece of JavaScript code into every HTML file
93
91
before serving it. This snippet is executed by the browser and opens a WebSocket
94
92
connection to the server, which in turn adds it to a list of viewers of this page.
95
93
96
-
The server can now send the message "update" to all viewers of a page
97
-
whenever the page is changed. The code snippet reacts to this message by
98
-
triggering a page reload (same as hitting `F5`). The update is triggered by the
99
-
callback mentioned above. When the file is not an HTML file, the viewers of _any_
100
-
HTML file are updated, since `LiveServer` currently does not keep track of which
101
-
HTML files reference what other files.
94
+
The server can now send the message "update" to all viewers of a page whenever the page is changed.
95
+
The code snippet reacts to this message by triggering a page reload.
96
+
The update is triggered by the callback mentioned above.
97
+
When the file is not an HTML file, the viewers of _any_ HTML file are updated, since `LiveServer` currently does not keep track of which HTML files reference what other files.
0 commit comments