LiveReload
This is a brand new LiveReload in version 2.0.0.
Installation
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
server.watch('static/*.stylus', 'make static')
# run a function
def alert():
print('foo')
server.watch('foo.txt', alert)
# output stdout into a file
server.watch('style.less', shell('lessc style.less', output='style.css'))
server.serve()
The Server class accepts parameters:
app: a wsgi application
watcher: a watcher instance, you don’t have to create one
server.watch
server.watch can watch a filepath, a directory and a glob pattern:
server.watch('path/to/file.txt')
server.watch('directory/path/')
server.watch('glob/*.pattern')
You can also use other library (for example: formic) for more powerful file adding:
for filepath in formic.FileSet(include="**.css"):
server.watch(filepath, 'make css')
You can delay a certain seconds to send the reload signal:
# delay 2 seconds for reloading
server.watch('path/to/file', delay=2)
server.serve
Setup a server with server.serve method. It can create a static server and a livereload server:
# use default settings server.serve() # livereload on another port server.serve(liveport=35729) # use custom host and port server.serve(port=8080, host='localhost')
shell
The powerful shell function will help you to execute shell commands. You can use it with server.watch:
server.watch('style.less', shell('lessc style.less', output='style.css'))
# commands can be a list
server.watch('style.less', shell(['lessc', 'style.less'], output='style.css'))
# working with Makefile
server.watch('assets/*.styl', shell('make assets', cwd='assets'))
Frameworks Integration
Livereload can work seamlessly with your favorite framework.
Django
Here is a little hint on Django. Change your manage.py file to:
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hello.settings")
from django.core.management 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
# server.watch('path/to/file', 'your command')
server.serve()
else:
execute_from_command_line(sys.argv)
When you execute ./manage.py livereload, it will start a livereload server.
Flask
Wrap Flask with livereload is much simpler:
# app is a Flask object app = create_app() server = Server(app.wsgi_app) # server.watch server.serve()
Bottle
Wrap the Bottle app with livereload server:
app = Bottle() server = Server(app) # server.watch server.serve()
Metadata
Release files for livereload 2.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| livereload-2.3.2.tar.gz | 18.5 kB | Without provenance | Details for livereload-2.3.2.tar.gz |
Release files / livereload-2.3.2.tar.gz
| Download URL | livereload-2.3.2.tar.gz |
|---|---|
| Size | 18.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5dabad9c47c53468244865d67882cc2f5a2ec69bc1bfd454392b78abbcb68a25
|
|
BLAKE2b-256 checksum How to use checksums |
44783734f142a26c3aa82c0df98a20f1a449ea94976913a74315fd4ee44b5148
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for livereload 2.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.