METADATA 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. Metadata-Version: 2.1
  2. Name: livereload
  3. Version: 2.6.2
  4. Summary: Python LiveReload is an awesome tool for web developers
  5. Home-page: https://github.com/lepture/python-livereload
  6. Author: Hsiaoming Yang
  7. Author-email: me@lepture.com
  8. License: BSD
  9. Platform: UNKNOWN
  10. Classifier: Development Status :: 4 - Beta
  11. Classifier: Environment :: Console
  12. Classifier: Environment :: Web Environment :: Mozilla
  13. Classifier: Intended Audience :: Developers
  14. Classifier: License :: OSI Approved :: BSD License
  15. Classifier: Natural Language :: English
  16. Classifier: Operating System :: MacOS :: MacOS X
  17. Classifier: Operating System :: POSIX :: Linux
  18. Classifier: Programming Language :: Python
  19. Classifier: Programming Language :: Python :: 2
  20. Classifier: Programming Language :: Python :: 2.7
  21. Classifier: Programming Language :: Python :: 3
  22. Classifier: Programming Language :: Python :: 3.5
  23. Classifier: Programming Language :: Python :: 3.6
  24. Classifier: Programming Language :: Python :: 3.7
  25. Classifier: Programming Language :: Python :: 3.8
  26. Classifier: Programming Language :: Python :: Implementation :: CPython
  27. Classifier: Programming Language :: Python :: Implementation :: PyPy
  28. Classifier: Topic :: Software Development :: Build Tools
  29. Classifier: Topic :: Software Development :: Compilers
  30. Classifier: Topic :: Software Development :: Debuggers
  31. Requires-Dist: six
  32. Requires-Dist: tornado (<6) ; python_version == "2.7"
  33. Requires-Dist: tornado ; python_version > "2.7"
  34. LiveReload
  35. ==========
  36. This is a brand new LiveReload in version 2.0.0.
  37. `Download on PyPi <https://pypi.python.org/pypi/livereload>`_
  38. Installation
  39. ------------
  40. Python LiveReload is designed for web developers who know Python.
  41. Install Python LiveReload with pip::
  42. $ pip install livereload
  43. If you don't have pip installed, try easy_install::
  44. $ easy_install livereload
  45. Command Line Interface
  46. ----------------------
  47. Python LiveReload provides a command line utility, ``livereload``, for starting a server in a directory.
  48. By default, it will listen to port 35729, the common port for `LiveReload browser extensions`_. ::
  49. $ livereload --help
  50. usage: livereload [-h] [-p PORT] [-w WAIT] [directory]
  51. Start a `livereload` server
  52. positional arguments:
  53. directory Directory to watch for changes
  54. optional arguments:
  55. -h, --help show this help message and exit
  56. -p PORT, --port PORT Port to run `livereload` server on
  57. -w WAIT, --wait WAIT Time delay before reloading
  58. .. _`livereload browser extensions`: http://feedback.livereload.com/knowledgebase/articles/86242-how-do-i-install-and-use-the-browser-extensions-
  59. 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.
  60. Script example: Sphinx
  61. ----------------------
  62. Here's a simple example script that rebuilds Sphinx documentation:
  63. .. code:: python
  64. #!/usr/bin/env python
  65. from livereload import Server, shell
  66. server = Server()
  67. server.watch('docs/*.rst', shell('make html', cwd='docs'))
  68. server.serve(root='docs/_build/html')
  69. Run it, then open http://localhost:5500/ and you can see the documentation changes in real time.
  70. Developer Guide
  71. ---------------
  72. The new livereload server is designed for developers. It can power a
  73. wsgi application now:
  74. .. code:: python
  75. from livereload import Server, shell
  76. server = Server(wsgi_app)
  77. # run a shell command
  78. server.watch('static/*.stylus', 'make static')
  79. # run a function
  80. def alert():
  81. print('foo')
  82. server.watch('foo.txt', alert)
  83. # output stdout into a file
  84. server.watch('style.less', shell('lessc style.less', output='style.css'))
  85. server.serve()
  86. The ``Server`` class accepts parameters:
  87. - app: a wsgi application
  88. - watcher: a watcher instance, you don't have to create one
  89. server.watch
  90. ~~~~~~~~~~~~
  91. ``server.watch`` can watch a filepath, a directory and a glob pattern::
  92. server.watch('path/to/file.txt')
  93. server.watch('directory/path/')
  94. server.watch('glob/*.pattern')
  95. You can also use other library (for example: formic) for more powerful
  96. file adding::
  97. for filepath in formic.FileSet(include="**.css"):
  98. server.watch(filepath, 'make css')
  99. You can delay a certain seconds to send the reload signal::
  100. # delay 2 seconds for reloading
  101. server.watch('path/to/file', delay=2)
  102. server.setHeader
  103. ~~~~~~~~~~~~~~~~
  104. ```server.setHeader``` can be used to add one or more headers to the HTTP
  105. response::
  106. server.setHeader('Access-Control-Allow-Origin', '*')
  107. server.setHeader('Access-Control-Allow-Methods', '*')
  108. server.serve
  109. ~~~~~~~~~~~~
  110. Setup a server with ``server.serve`` method. It can create a static server
  111. and a livereload server::
  112. # use default settings
  113. server.serve()
  114. # livereload on another port
  115. server.serve(liveport=35729)
  116. # use custom host and port
  117. server.serve(port=8080, host='localhost')
  118. # open the web browser on startup, based on $BROWSER environment variable
  119. server.serve(open_url_delay=5, debug=False)
  120. shell
  121. ~~~~~
  122. The powerful ``shell`` function will help you to execute shell commands. You
  123. can use it with ``server.watch``::
  124. # you can redirect command output to a file
  125. server.watch('style.less', shell('lessc style.less', output='style.css'))
  126. # commands can be a list
  127. server.watch('style.less', shell(['lessc', 'style.less'], output='style.css'))
  128. # working with Makefile
  129. server.watch('assets/*.styl', shell('make assets', cwd='assets'))
  130. Frameworks Integration
  131. ----------------------
  132. Livereload can work seamlessly with your favorite framework.
  133. Django
  134. ~~~~~~
  135. For Django there is a management command included.
  136. To use simply
  137. - add ``'livereload'`` to your ``INSTALLED_APPS`` and
  138. - then run ``./manage.py livereload``.
  139. For available options like host and ports please refer to ``./manage.py livereload -h``.
  140. To automagically serve static files like the native ``runserver`` command you have to use `dj-static <https://github.com/kennethreitz/dj-static>`_. (follow the simple instructions there).
  141. Flask
  142. ~~~~~
  143. Wrap Flask with livereload is much simpler:
  144. .. code:: python
  145. # app is a Flask object
  146. app = create_app()
  147. # remember to use DEBUG mode for templates auto reload
  148. # https://github.com/lepture/python-livereload/issues/144
  149. app.debug = True
  150. server = Server(app.wsgi_app)
  151. # server.watch
  152. server.serve()
  153. Bottle
  154. ~~~~~~
  155. Wrap the ``Bottle`` app with livereload server:
  156. .. code:: python
  157. # Without this line templates won't auto reload because of caching.
  158. # http://bottlepy.org/docs/dev/tutorial.html#templates
  159. bottle.debug(True)
  160. app = Bottle()
  161. server = Server(app)
  162. # server.watch
  163. server.serve()
  164. Security Report
  165. ---------------
  166. To report a security vulnerability, please use the
  167. `Tidelift security contact <https://tidelift.com/security>`_.
  168. Tidelift will coordinate the fix and disclosure.