-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
47 lines (36 loc) · 1.14 KB
/
app.js
File metadata and controls
47 lines (36 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const express=require('express');
const bodyParser=require('body-parser');
const mongoose=require('mongoose');
const assert=require('assert');
const app=express();
const Tutorials=require('./schema.js');
var url=//localhost:27017/MyDb;
mongoose.connect(url);
const db=mongoose.connection;
/*app.set('view engine','pug');
app.set('views','./views');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended:true}));
app.use(express.static('public'));
app.get('/home',function(req,res){
res.render('index',{
name : "tutorialpoint",
url :"http://www.tutorialpoint.com" });
});
app.get('/form',function(req,res){
res.render('form');
});
app.post('/',function(req,res){
console.log(req.body);
res.send("request recieved");
});
app.get('/',function(req,res){
res.send("welcome to the express app");
});
/*app.get('/:id',function(req,res){
res.send("the specified id is"+ req.params.id);
});*/
db.on('error',console.error.bind(console,'Connection Error'));
app.listen(3000,function(){
console.log("listening to the server at 3000");
});