node-live-color

by rsp

GitHub Readme.md

node-live-color

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.

Deploy to Heroku

Click this button to deploy this app to Heroku:

Deploy to Heroku

Installation

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

Running

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

Changing color

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 #.

Issues

For any bug reports or feature requests please post an issue on GitHub.

Author

Rafał Pocztarski
Follow on GitHub Follow on Twitter
Follow on Stack Exchange

License

MIT License (Expat). See LICENSE.md for details.