From 121c183b1b798dbbaf5620b8e38a27ee6948ffce Mon Sep 17 00:00:00 2001 From: z3r0Luck Date: Fri, 12 Jun 2020 21:33:12 +0000 Subject: [PATCH] Delete 'server.js.save' --- server.js.save | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 server.js.save diff --git a/server.js.save b/server.js.save deleted file mode 100644 index 8812caf..0000000 --- a/server.js.save +++ /dev/null @@ -1,47 +0,0 @@ - - -// declaring dependencies -const express = require('express'); -const bodyParser= require('body-parser') -const app = express(); -// Make sure you place body-parser before your CRUD handlers! -app.use(bodyParser.urlencoded({ extended: true })) - -// Constants -const PORT = 8080; -const HOST = '0.0.0.0'; - -var MongoClient = require('mongodb').MongoClient; -var connectionString = "mongodb://10.0.5.3:27017/"; - -MongoClient.connect(connectionString, { useUnifiedTopology: true }) - .then(client => { - console.log('Connected to Database') - const db = client.db('cloudDB') - const quotesCollection = db.collection('mycollection') - - - - app.post('/quotes', (req, res) => { - quotesCollection.insertOne(req.body) - .then(result => { - res.redirect('/') - }) - .catch(error => console.error(error)) - }) - - app.get('/', (req, res) => { - const cursor = db.collection('quotes').find().toArray() - .then(results => { - console.log(results) - }) - res.sendFile(__dirname + '/index.html') - }) - - app.listen(PORT, HOST); - - }) - - -console.log(`Running on http://${HOST}:${PORT}`); -