Coder Social home page Coder Social logo

smashpapst2 / python-livereload Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lepture/python-livereload

0.0 2.0 0.0 289 KB

livereload server in python

Home Page: http://livereload.readthedocs.org/en/latest/

License: BSD 3-Clause "New" or "Revised" License

python-livereload's Introduction

Python LiveReload

LiveReload Server in Python Version.

Web Developers need to refresh a browser everytime when he saved a file (css, javascript, html), it is really boring. LiveReload will take care of that for you. When you saved a file, your browser will refresh itself. And what's more, it can do some tasks like compiling less to css before the browser refreshing.

Installation

Python LiveReload is designed for web developers who know Python.

Install python-livereload

Install Python LiveReload with pip:

$ pip install livereload

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

$ easy_install livereload

Install Browser Extensions

A browser extension is not required, you can insert a script into your html page manually:

<script type="text/javascript" src="http://127.0.0.1:35729/livereload.js"></script>

But a browser extension will make your life easier, available extensions:

  • Chrome Extension
  • Safari Extension
  • Firefox Extension

Visit: http://help.livereload.com/kb/general-use/browser-extensions

Quickstart

LiveReload is designed for more complex tasks, not just for refreshing a browser. But you can still do the simple task.

Assume you have livereload and its extension installed, and now you are in your working directory. With command:

$ livereload [-p port]

your browser will reload, if any file in the working directory changed.

LiveReload as SimpleHTTPServer

Livereload server can be a SimpleHTTPServer:

$ livereload -p 8000

It will set up a server at port 8000, take a look at http://127.0.0.1:8000. Oh, it can livereload!

IF YOU ARE NOT USING IT AS A HTTP SERVER, DO NOT ADD THE PORT OPTION.

Guardfile

More complex tasks can be done by Guardfile. Write a Guardfile in your working directory, the basic syntax:

#!/usr/bin/env python
from livereload.task import Task

Task.add('static/style.css')
Task.add('*.html')

Now livereload will only guard static/style.css and html in your workding directory.

But python-livereload is more than that, you can specify a task before refreshing the browser:

#!/usr/bin/env python
from livereload.task import Task
from livereload.compiler import lessc

Task.add('style.less', lessc('style.less', 'style.css'))

And it will compile less css before refreshing the browser now.

Linux

If you're using python-livereload under Linux, you should also install pyinotify, as it will greatly improve responsiveness and reduce CPU load.

You may see errors such as:

[2013-06-19 11:11:07,499 pyinotify ERROR] add_watch: cannot watch somefile WD=-1, Errno=No space left on device (ENOSPC)

If so, you need to increase the number of "user watches". You can either do this temporarily by running (as root):

echo 51200 > /proc/sys/fs/inotify/max_user_watches

To make this change permanent, add the following line to /etc/sysctl.conf and reboot:

fs.inotify.max_user_watches = 51200

Others

If you are on a Mac, you can buy LiveReload2.

If you are a rubist, you can get guard-livereload.

python-livereload's People

Contributors

lepture avatar skitazaki avatar uniphil avatar andrewnelis avatar adq avatar kespindler avatar ralsina avatar zviki avatar

Watchers

James Cloos avatar Paul S. Mash avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.