Sign inSign up

dmoutinho/node-simple-server

By dmoutinho

Updated over 6 years ago

Image
0

169

dmoutinho/node-simple-server repository overview

docker run --rm -p 3000 --name my-running-script -v "$PWD":/usr/src/app -w /usr/src/app node:8 node your-daemon-or-script.js

//your-daemon-or-script.js var http = require('http'); var url = require("url");

http.createServer(function (req, res) {

var path = url.parse(req.url).pathname;

if( path==="/write-public") {

	res.writeHead(200, {'Set-Cookie':'username=John Doe;domain=essilor.com.br','Content-Type':'text/plain'});
	res.write('Write cookie: username=John Doe;domain=essilor.com.br');
	

} else if( path==="/write-private" ) {

	res.writeHead(200, {'Set-Cookie':'username-httponly=John Doe;domain=essilor.com.br;HttpOnly','Content-Type':'text/plain'});
	res.write('Write cookie: username-httponly=John Doe;domain=essilor.com.br;HttpOnly');	  

} else if(path==="/read") {

	res.writeHead(200, {'Content-Type': 'text/plain'});
	//res.write('Read cookie: '+JSON.stringify(req.headers));
	res.write('Read cookie: '+req.headers.cookie);

} else {

	res.writeHead(200, {'Content-Type': 'text/plain'});
	res.write('Other: '+path);
		

}

res.end();

}).listen(3000);

Tag summary

Content type

Image

Digest

Size

330.2 MB

Last updated

over 6 years ago

docker pull dmoutinho/node-simple-server