Skip to content

Changing website background color live with Node/Express/Socket.io

License

Notifications You must be signed in to change notification settings

yogeeshsj/node-live-color

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Changing website background color live with Node/Express/Socket.io

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 45.5%
  • HTML 45.3%
  • CSS 9.2%