NB UPDATE 2015-11-05:This method is now obsolete. I am now simply using webpack's development server.
NB: this is an improved way over the original way.
sourceFirst, you need to install
pip install livereload
livereloadutility for starting a server in a directory (that relies on the old method of using a
Guardfile), but rather write your own python script and execute it. E.g. the one I have used (placed in the directory of my sources) is:
cat livereload-server.py #!/usr/bin/env python from livereload import Server server = Server() server.watch('*.html', delay=1) server.serve(liveport=35729, host='localhost') #this script is apparently automatically serving at 5500 #I am not sure then, what the below line is doing: #server.serve(port=1717, host='localhost')I then simply run it with:
./livereload-server.pyTypical output is:
[I 150917 18:09:17 server:271] Serving on http://localhost:5500 [I 150917 18:09:17 handlers:58] Start watching changes [I 150917 18:09:17 handlers:60] Start detecting changes [I 150917 18:09:18 handlers:131] Browser Connected: http://localhost:5500/foo.html [I 150917 18:09:18 handlers:78] Ignore: foo.htmlNotice that a message to the effect that the browser was connected is displayed. This obviously requires installing the LiveReload plugin extension (e.g. in Chrome). I then point my browser to:
http://localhost:5500/foo.html... and can view the changes without the need to manually reload. NB:Where the port number 5500 is a mystery to me. It does not appear in the script and I don't know how to change it.
curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python sudo pip install livereloador, alternatively:
sudo apt-get install python-pip sudo pip install livereload... subsequently,
cdto the directory containing the files to be monitored and create the following file named
#!/usr/bin/env python from livereload.task import Task Task.add('*.css') Task.add('*.html') Task.add('css/*.css')... then start LiveReload with (for port 1717):
livereload -p 1717 .Following the above steps that the page is rendered in the following URL: