Express hello world
来源:互联网 发布:mmd动作数据怎么用 编辑:程序博客网 时间:2024/06/06 00:21
http://expressjs.com/en/starter/hello-world.html
一、安装node.js ,Express 之后, 建立一个index.js ,下面是服务器端的代码:
const express = require('express')
const app = express()app.get('/', function (req, res) {
res.send('Hello World!')
})
app.listen(3000, function () {
console.log('Example app listening on port 3000!')
})
1、 app.get('/', function (req, res) {
res.send('Hello World!')
})
回调函数返回结果。
/:表示浏览器上的url地址是根目录,服务器只响应/目录的请求,其它则是404错误。
app.get():就是服务器传回一客户需要的信息。
2、表示服务器在3000口监听,有浏览器请求,就调用app.get传回数据给浏览器。
app.listen(3000, function () {
console.log('Example app listening on port 3000!')
二、执行
D:\setupsoft\nodes>node newapp/index.js
Example app listening on port 3000!
三、在浏览器输入:http://localhost:3000/
阅读全文
0 0
- Express hello world
- node.js + express 初体验【hello world】
- node.js + express 初体验【hello world】
- express系列-入门:简介、安装、hello、world
- Node.js学习笔记6【express--hello world】
- Node.Js + express, run "hello world " in windows 8.1
- Node入门训练【7】【用express写出hello world】
- Hello World!【Hello World】
- Express Hello
- Express-hello
- Hello, world!
- Hello World!
- Hello world!
- Hello World!
- Hello World!
- hello world!
- Hello World !
- Hello,World!
- Linux iptables
- Cleaning Shifts
- NC中常用到的公共工具类PubUtils
- Bootstrap实例2---导航栏的实现
- IntelliJ Idea 快捷键列表
- Express hello world
- Android视频播放 的几种方式
- Unity1--生命周期函数和颜色配置
- HDU 6152-Friend-Graph(ccpc)
- 启用lumen的user token认证
- BZOJ[1367][Baltic2004]Sequence 可并堆
- Evaluate the value of an arithmetic expression in Reverse Polish Notation.
- 算法入门经典——果园里的树
- 23.odoo入门——工作杂记