How to reload only with HTTP request? (i.e.: use external watcher)

Open
#211 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
api, backend

Research direction

Start at livereload/server.py lines 312-313 referenced in the issue and compare Server.serve() with the shown Server/application setup. Determine whether an external watcher, or no watcher, can trigger a browser reload only through /forcereload; done means the supported behavior and usage are clear.

Written by the indexing model from the issue text.

Description

type: question

I would like to reload web browser view only when a request to /forcereload is received, not on any file change, because I am using an external watcher.

I can do that like so:

    url = 'http://{host}:{port}'.format(host=host, port=port)

    # Create server application
    server = Server()
    server.root = str(config['output_path'])
    server.application(
        port, host, liveport=None, debug=True, live_css=True)

    # Open web browser
    threading.Thread(target=webbrowser.open, args=(url, )).start()

    # Start Tornado IOLoop
    add_reload_hook(lambda: IOLoop.instance().close(all_fds=True))
    IOLoop.instance().start()

Which is basically the same as Server.serve(), but getting rid of:

https://github.com/lepture/python-livereload/blob/d5f6a2e3fab5e4308dc744e26792ce83581703d9/livereload/server.py#L312-L313

Is there an easier/cleaner way? Is using an external watcher (or not using any at all) supported?

Dominant language
Python
Stars
1.1k
Forks
149
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lepture/python-livereload

All issues in lepture/python-livereload

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.