How to Start HTTP File Sharing on LAN (ft. AdGuard)
Preface: Why HTTP?
Apps like AdGuard or Adblock can take a URL for custom filters. The application isn’t limited to simply adblocks though. This inherently works similar to how RSS feed used to work. An app can simply pull a file to keep its database up to date. As to where the file is provided in URL.
Ideally, an app should have other methods to simply pull a file from local or cloud storage. Going back to the earlier example, simply uploading your file to a web server would broadcast a custom filter to world wide web. This is not a desirable behavior. It is a custom filter, most likely a small set of filters fit for one or few users’ need. If so, we can limit the ‘share’ to the local network.
The instruction I am writing is for Python 3 and up. Depending your Python environment, you would be calling the module with
python3, especially if you are running both Python 2 and 3. What we will be doing is rather simple. Change the directory to where the file in question is located, then start a simple HTTP server:
cd /path/to/dir python -m http.server
Once the server is running, from your devices, you can access a file like this:
The address will be the ip address for your computer. You can set it up so that the IP address is reserved from the router, so that you wouldn’t need to tweak the address on all devices every time there’s a change. Don’t forget to Ctrl+C to terminate the server once all devices got the file; the server will stop once the terminal window is closed, but no need to take chances.