Example for Stack Overflow answer:
It is a server that serves a page that changes color when
a new color is sent in a request to a POST /color
endpoint.
Click this button to deploy this app to Heroku:
Clone the git repo:
git clone https://github.com/rsp/node-live-color.git
or download the ZIP file:
Inside the project directory install dependencies:
npm i
Start the server:
npm start
And access the URL shown in the browser. By default it's:
but you can start the server listening on a differet port:
PORT=4444 npm start
Send color=HTMLCOLOR in the body
with Content-Type: application/x-www-form-urlencoded
to POST /color
endpoint:
curl -X POST -d color=#2ecc71 http://localhost:3338/color
curl -X POST -d color=#639 http://localhost:3338/color
curl -X POST -d color=black http://localhost:3338/color
Or using a GET /color/:color
endpoint for convenience:
curl -X http://localhost:3338/color/+2ecc71
curl -X http://localhost:3338/color/+639
curl -X http://localhost:3338/color/black
Note the +
instead of #
.
For any bug reports or feature requests please post an issue on GitHub.
MIT License (Expat). See LICENSE.md for details.