Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gigsforlinux/0d32c9752ed4af75343665df8c0f8c4e to your computer and use it in GitHub Desktop.
Save gigsforlinux/0d32c9752ed4af75343665df8c0f8c4e to your computer and use it in GitHub Desktop.
I'll Do Anything Goes With MEAN Stack For You
apt-get update
apt install mongodb
systemctl start mongodb
systemctl enable mongodb
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
git clone https://github.com/meanjs/mean
cd mean
vim server.js
#########################
remove old lines and
Add the following lines:
const express = require('express');
const MongoClient = require('mongodb').MongoClient;
const app = express();
app.use('/', (req, res) => {
MongoClient.connect("mongodb://localhost:27017/test", function(err, db){
db.collection('Example', function(err, collection){
collection.insert({ pageHits: 'pageHits' });
db.collection('Example').count(function(err, count){
if(err) throw err;
res.status(200).send('Page Hits: ' + Math.floor(count/2));
});
});
});
});
app.listen(3000);
console.log('Server running at http://localhost:3000/');
module.exports = app;
############################
gulp
http://server-ip:3000
@gigsforlinux
Copy link
Author

Screenshot from 2022-08-03 22-58-56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment