Package list python-livereload / lintian-fixes/main

Tree @lintian-fixes/main (Download .tar.gz)


This is a brand new LiveReload in version 2.0.0.

`Download on PyPi <>`_


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] [-w WAIT] [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
      -w WAIT, --wait WAIT  Time delay before reloading

.. _`livereload browser extensions`:

Older versions of Python LiveReload used a ``Guardfile`` to describe optional additional rules for files to watch and build commands to run on changes.  This conflicted with other tools that used the same file for their configuration and is no longer supported since Python LiveReload version 2.0.0.  Instead of a ``Guardfile`` you can now write a Python script using very similar syntax and run it instead of the command line application.

Script example: Sphinx

Here's a simple example script that rebuilds Sphinx documentation:

.. code:: python

    #!/usr/bin/env python
    from livereload import Server, shell
    server = Server()'docs/*.rst', shell('make html', cwd='docs'))

Run it, then open http://localhost:5500/ and you can see the documentation changes in real time.

Developer Guide

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

.. code:: python

    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)


```server.setHeader``` can be used to add one or more headers to the HTTP 

    server.setHeader('Access-Control-Allow-Origin', '*')
    server.setHeader('Access-Control-Allow-Methods', '*')


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')

    # open the web browser on startup, based on $BROWSER environment variable
    server.serve(open_url_delay=5, debug=False)

    # set a custom default file to open


The powerful ``shell`` function will help you to execute shell commands. You
can use it with ````::

    # you can redirect command output to a file'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.


For Django there is a management command included.

To use simply

- add ``'livereload'`` to your ``INSTALLED_APPS`` and
- then run ``./ livereload``.

For available options like host and ports please refer to ``./ livereload -h``.

To automagically serve static files like the native ``runserver`` command you have to use `dj-static <>`_. (follow the simple instructions there).


Wrap Flask with livereload is much simpler:

.. code:: python

    # app is a Flask object
    app = create_app()

    # remember to use DEBUG mode for templates auto reload
    app.debug = True

    server = Server(app.wsgi_app)


Wrap the ``Bottle`` app with livereload server:

.. code:: python

    # Without this line templates won't auto reload because of caching.

    app = Bottle()
    server = Server(app)

Security Report

To report a security vulnerability, please use the
`Tidelift security contact <>`_.
Tidelift will coordinate the fix and disclosure.