码迷,mamicode.com
首页 > Web开发 > 详细

nodejs: express basic

时间:2020-06-06 16:53:14      阅读:76      评论:0      收藏:0      [点我收藏+]

标签:word   request   local   expr   started   解决   console   基本   upgrading   

express: web application framework

第一个express 基本应用:

const express = require(‘express‘);
const port = 3000;

const app = express();

app.use((req, res) => {
    res.json("hello express")
});

app.get(‘/users/:id‘, (req, res) => {
    const { id } = req.params;
    res.json({
        id,
        name: "Nyan Shen"
    })
})

app.listen(port, () => {
    console.log(`server starded listening at http://localhost:${port}`)
})

/**
let http = require(‘http‘);

let server = http.createServer((req, res) => {
    res.end("hello server test")
});

server.listen(3000, ‘127.0.0.1‘, () => {
    console.log(‘server started...‘)
})
*/

遇到问题:Client does not support authentication protocol requested by server; consider upgrading MySQL client

解决问题:

use mysql;
alter user ‘root‘@‘localhost‘ identified with mysql_native_password by ‘数据库密码‘;
flush privileges;

 

nodejs: express basic

标签:word   request   local   expr   started   解决   console   基本   upgrading   

原文地址:https://www.cnblogs.com/Nyan-Workflow-FC/p/13055241.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!