zoukankan      html  css  js  c++  java
  • 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!") })

  • 相关阅读:
    初賽
    SA
    高斯-约旦消元法
    AC自动机
    KMP
    关于scanf
    网络流
    常用SQL语句
    Java开发中的23种设计模式详解(转)
    generatorConfig.xml
  • 原文地址:https://www.cnblogs.com/LilyLiya/p/14397170.html
Copyright © 2011-2022 走看看