最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

Can get('',function(req,res){}不能称为服务器

IT培训 admin 4浏览 0评论

Can get('/',function(req,res){}不能称为服务器

我正在从mysql获取数据,并使用它在node.js上创建d3js图。我了解到服务器只能由模块“ http”和“请求”构成。如果我不使用它们,而使用

app.get('/', function (req, res) {
    res.render('index', {
       //
    });
});

app.listen(port, function () {
    console.log('running server on port ' + port) 
});

他们正在解决相同的目的。我缺少服务器的什么概念?这种方式获取数据的局限性是什么?

回答如下:

使用express Web框架:

const express = require('express')
const app = express()

app.get('/', function (req, res) {
  res.send('Hello World')
})


let port=3000;
app.listen(port, function () {
    console.log('running server on port ' + port) 
});

Can get('/',function(req,res){}不能称为服务器

我正在从mysql获取数据,并使用它在node.js上创建d3js图。我了解到服务器只能由模块“ http”和“请求”构成。如果我不使用它们,而使用

app.get('/', function (req, res) {
    res.render('index', {
       //
    });
});

app.listen(port, function () {
    console.log('running server on port ' + port) 
});

他们正在解决相同的目的。我缺少服务器的什么概念?这种方式获取数据的局限性是什么?

回答如下:

使用express Web框架:

const express = require('express')
const app = express()

app.get('/', function (req, res) {
  res.send('Hello World')
})


let port=3000;
app.listen(port, function () {
    console.log('running server on port ' + port) 
});
发布评论

评论列表 (0)

  1. 暂无评论