{"id":8220,"library":"httpwatcher","title":"HTTP Watcher (Python Library)","description":"httpwatcher is a Python library and command-line utility for serving static files with live reload functionality, primarily intended for web development. It leverages the Tornado asynchronous web framework for its HTTP and WebSocket server capabilities. The current version is 0.5.2. Releases appear to be ad-hoc, tied to development needs rather than a fixed cadence.","status":"active","version":"0.5.2","language":"en","source_language":"en","source_url":"https://github.com/thanethomson/httpwatcher","tags":["web server","static files","live reload","development","tornado"],"install":[{"cmd":"pip install httpwatcher","lang":"bash","label":"Install stable version"},{"cmd":"pip install -U httpwatcher","lang":"bash","label":"Upgrade to latest version"}],"dependencies":[{"reason":"Core asynchronous web framework for HTTP and WebSocket server.","package":"tornado","optional":false}],"imports":[{"note":"Convenience method to quickly set up and run a server.","symbol":"watch","correct":"import httpwatcher\nhttpwatcher.watch(...)"},{"note":"For more fine-grained control over the server and I/O loop.","symbol":"HttpWatcherServer","correct":"from httpwatcher import HttpWatcherServer"}],"quickstart":{"code":"import os\nfrom httpwatcher import HttpWatcherServer\nfrom tornado.ioloop import IOLoop\n\n# Create a dummy directory and file for demonstration\nif not os.path.exists('my_static_app'):\n    os.makedirs('my_static_app')\nwith open('my_static_app/index.html', 'w') as f:\n    f.write('<!DOCTYPE html><html><head><title>Test</title></head><body><h1>Hello, httpwatcher!</h1></body></html>')\n\n# Instantiate the server\nserver = HttpWatcherServer(\n    root='my_static_app',\n    host='127.0.0.1',\n    port=5555,\n    base_path='/',\n    open_browser=False,\n    verbose=True\n)\n\n# Start the server (usually in a separate thread or process for non-blocking operations)\n# For a quick runnable example, we'll run it directly, which will block.\n# In a real application, you might use IOLoop.current().start() in a thread.\nprint(f\"Serving 'my_static_app' at http://127.0.0.1:5555\")\nprint(\"Press Ctrl+C to stop.\")\n\ntry:\n    server.start() # This blocks the current thread\nexcept KeyboardInterrupt:\n    print(\"Server stopped.\")\nfinally:\n    server.stop()\n    # Clean up dummy files/directories\n    os.remove('my_static_app/index.html')\n    os.rmdir('my_static_app')","lang":"python","description":"This example demonstrates how to set up and run an `httpwatcher` server programmatically. It serves files from a 'my_static_app' directory, includes a basic `index.html` file, and starts the server on `http://127.0.0.1:5555`. Changes to files in 'my_static_app' would trigger a live reload in connected browsers. The `open_browser=False` argument is used for programmatic control."},"warnings":[{"fix":"Always qualify searches with 'python library' or 'pypi' when looking for information on this specific package.","message":"This Python library 'httpwatcher' is distinct from the 'HttpWatch' browser extension for HTTP debugging. Searching for issues or documentation might lead to irrelevant results for the browser tool.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Do not deploy applications using `httpwatcher` as a production web server. Use production-ready web servers like Nginx, Apache, Gunicorn, or uWSGI instead.","message":"httpwatcher is explicitly designed for development purposes and is NOT intended for production environments. It has 'only basic security checks' and may have critical vulnerabilities not addressed in smaller sub-projects.","severity":"breaking","affected_versions":"All versions"},{"fix":"Ensure that all HTML files intended for live reloading contain a `</body>` tag. For non-HTML content, live reload will not function as expected.","message":"The live reload functionality relies on injecting `<script>` tags before the `</body>` closing tag. HTML content without a `</body>` tag (e.g., partial HTML files or non-HTML content) will not receive the live reload script injection.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure `pip install httpwatcher` completed successfully. If using a virtual environment, ensure it is activated. On some systems, you might need to specify the full path to the executable, e.g., `python -m httpwatcher`.","cause":"The `httpwatcher` command-line utility is not in your system's PATH, or the package was not installed correctly.","error":"httpwatcher: command not found"},{"fix":"Stop the conflicting process, or specify a different port using the `--port` (command-line) or `port` (library) argument, e.g., `httpwatcher --port 8000`.","cause":"Another process is already using the specified host and port (defaulting to 127.0.0.1:5555).","error":"Address already in use"},{"fix":"Activate your Python virtual environment (if applicable) and run `pip install httpwatcher`. Verify installation by running `pip show httpwatcher`.","cause":"The `httpwatcher` package is not installed in the Python environment where you are trying to import it.","error":"ModuleNotFoundError: No module named 'httpwatcher'"}]}