Skip to content

Instantly share code, notes, and snippets.

@allexiusw
Last active November 15, 2019 16:04
Show Gist options
  • Save allexiusw/a7d8018ced11d2fc2beb6cd7e1b873e3 to your computer and use it in GitHub Desktop.
Save allexiusw/a7d8018ced11d2fc2beb6cd7e1b873e3 to your computer and use it in GitHub Desktop.
Install NodeJS, CouchDB and nano
#install base-tools
sudo apt-get install curl software-properties-common
#Download the setup
curl -sL https://deb.nodesource.com/setup_13.x | sudo bash -
#install nodejs on Debian
sudo apt-get install nodejs
#get version node
nodejs -v
#get version
npm -v
#install nano
sudo npm install -g nano
#add script in nodejs
nano http_server.js
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
var nano = require('nano')('http://localhost:5984');
info="";
nano.db.list().then((body) => {
// body is an array
body.forEach((db) => {
info += db+"<br/>";
console.log(db);
});
res.end(info);
});
}).listen(3000, "0.0.0.0");
console.log('running in http://35.222.200.137:3000/');
#save the data
#start the server
node http_server.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment