Last active
August 4, 2022 19:13
-
-
Save gigsforlinux/0d32c9752ed4af75343665df8c0f8c4e to your computer and use it in GitHub Desktop.
I'll Do Anything Goes With MEAN Stack For You
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
Author
gigsforlinux
commented
Aug 4, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment