Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
livereload server in python



This is a brand new LiveReload in version 2.0.0.

Downloads Version


Python LiveReload is designed for web developers who know Python.

Install Python LiveReload with pip:

$ pip install livereload

If you don't have pip installed, try easy_install:

$ easy_install livereload

Command Line Interface

Python LiveReload provides a command line utility, livereload, for starting a server in a directory.

By default, it will listen to port 35729, the common port for LiveReload browser extensions.

$ livereload --help
usage: livereload [-h] [-p PORT] [directory]

Start a `livereload` server

positional arguments:
  directory             Directory to watch for changes

optional arguments:
  -h, --help            show this help message and exit
  -p PORT, --port PORT  Port to run `livereload` server on

Developer Guide

The new livereload server is designed for developers. It can power a wsgi application now:

from livereload import Server, shell

server = Server(wsgi_app)

# run a shell command'static/*.stylus', 'make static')

# run a function
def alert():
    print('foo')'foo.txt', alert)

# output stdout into a file'style.less', shell('lessc style.less', output='style.css'))


The Server class accepts parameters:

  • app: a wsgi application
  • watcher: a watcher instance, you don't have to create one can watch a filepath, a directory and a glob pattern:'path/to/file.txt')'directory/path/')'glob/*.pattern')

You can also use other library (for example: formic) for more powerful file adding:

for filepath in formic.FileSet(include="**.css"):, 'make css')

You can delay a certain seconds to send the reload signal:

# delay 2 seconds for reloading'path/to/file', delay=2)


Setup a server with server.serve method. It can create a static server and a livereload server:

# use default settings

# livereload on another port

# use custom host and port
server.serve(port=8080, host='localhost')


The powerful shell function will help you to execute shell commands. You can use it with'style.less', shell('lessc style.less', output='style.css'))

# commands can be a list'style.less', shell(['lessc', 'style.less'], output='style.css'))

# working with Makefile'assets/*.styl', shell('make assets', cwd='assets'))

Frameworks Integration

Livereload can work seamlessly with your favorite framework.


Here is a little hint on Django. Change your file to:

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hello.settings")

    from import execute_from_command_line

    if 'livereload' in sys.argv:
        from django.core.wsgi import get_wsgi_application
        from livereload import Server
        application = get_wsgi_application()
        server = Server(application)

        # Add your watch
        #'path/to/file', 'your command')

When you execute ./ livereload, it will start a livereload server.


Wrap Flask with livereload is much simpler:

# app is a Flask object
app = create_app()

server = Server(app.wsgi_app)


Wrap the Bottle app with livereload server:

app = Bottle()
server = Server(app)
Something went wrong with that request. Please try again.