Raspberry PI Zero Stock Check
A high-speed, cached stock checker for the Raspberry PI Zero through screen-scraping.
Help is welcome, but my time is limited so if you have a suggestion, enhancement or bug fix then please raise an issue to begin a conversation.
Once an issue is open we can can talk about the proposed change in the open. Once we've figured out what needs to be done then you can go ahead and raise a PR and it's very likely to get merged.
Installation (easy way)
Using latest version of Docker and docker-compose:
$ git clone https://github.com/alexellis/pi_zero_stock $ docker-compose up -d
Manual installation or development:
- Install Node.js 4.x, Redis
npm installin stock_fetch and web folders
npm startin both folders.
Set up a hosts entry in /etc/hosts for redis to localhost, or set the environmental variable 'REDIS' to localhost before starting any of the nodes processes.
I've implemented endpoints for the following stores:
To extend the code and add a new endpoint look at the
stock_fetch project and add a new file under the
fetch folder. This also needs to be updated in the entrypoint of
Accessing the API:
curl http://localhost:3000/stock/pimoroni/ curl http://localhost:3000/stock/pisupply/ curl http://localhost:3000/stock/pihut/
- 200 is given if cache is valid and the stock will be returned as true or false.
- 202 means the check was in progress, send the request again.
Viewing in web-browser
Access the following:
Hosting the site
- See the Docker installation
- Use nginx to forward requests on port 80 to the local machine on port 3000
[x] Must have - hardening for failures during scrape [x] Should have - total stock numbers for any Raspberry PI bundles/products by store. [x] Should have - (Static site) Angular 1.x (via CDN) for binding stock results. [ ] Should have - Switch to pm2 for the node processes [x] Should have - coloured bootstrap wells or pills for in/out of stock. [ ] Could have - web hooks (posting to Twitter) [x] Could have - show stock for other suppliers. (adafruit) [ ] Could have - show stock units for individual SKUs, rather than (or in addition to) just one total-per-shop