Mongoose With Express _0: Basic Setup

  • Basic Setup (Mongoose  +  Express): 
  1. mkdir test
  2. cd test
  3. npm init -y
  4. npm i express ejs mongoose

  5. touch index.js

  6. mkdir views
  7. nodemon index.js
index.js

const express = require('express'); const app = express(); const path = require('path'); const mongoose = require('mongoose'); mongoose.connect('mongodb://localhost:27017/farmStand', { useNewUrlParser: true, useUnifiedTopology: true }) .then(() => { console.log("MONGO CONNECTION OPEN!!!") }) .catch(err => { console.log("OH NO MONGO CONNECTION ERROR!!!!") console.log(err) }) app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'ejs'); app.get('/dog', (req, res) => { res.send('Woof!') }) app.listen('3000', () => { console.log("APP IS LISTENING ON PORT 3000!") })

Mongoose With Express _0:  Basic Setup

Mongoose With Express _0:  Basic Setup

 

上一篇:使用 U 盘镜像安装 CentOS 8 卡在 [OK] Reached target Basic System 不动无法继续安装


下一篇:BUUCTF reverse [UTCTF2020]basic-re