MIMIC 以太坊医疗项目开发(1) Express Web Server介绍
Express 是一個(gè)很小規(guī)模的靈活的 Node.js Web 應(yīng)用程序開發(fā)框架,為 Web 和移動(dòng)應(yīng)用程序提供一組強(qiáng)大的功能。使用 Express 可以快速地搭建一個(gè)完整功能的網(wǎng)站,它提供了精簡(jiǎn)的基本 Web 應(yīng)用程序功能,而不會(huì)隱藏您了解和青睞的 Node.js 功能。使用 Express 可以快速地搭建一個(gè)完整功能的網(wǎng)站。
1. 安裝
-
npm install -g express –registry=https://registry.npm.taobao.org
-
npm init
生成package.json
{
“name”: “code”,
“version”: “1.0.0”,
“description”: “”,
“main”: “index.js”,
“scripts”: {
“test”: “echo “Error: no test specified” && exit 1”
},
“author”: “”,
“l(fā)icense”: “ISC”,
“dependencies”: {
“express”: “^4.17.1”
}
} -
npm install
-
npm install express --save
安裝命令工具
- npm install -g express-generator
- express --version
最好設(shè)置NODE_PATH的環(huán)境變量
2. helloworld.js示例代碼
// 引入 express 模塊 var express = require('express');// 創(chuàng)建 express 實(shí)例 var app = express();// 響應(yīng)HTTP的GET方法 app.get('/', function (req, res) { res.send('Hello World!'); });// 監(jiān)聽到8000端口 app.listen(8000, function () { console.log('Hello World is listening at port 8000'); });執(zhí)行“node HelloExpress.js”命令,在瀏覽器輸入”localhost:8000” 則會(huì)看到:
總結(jié)
以上是生活随笔為你收集整理的MIMIC 以太坊医疗项目开发(1) Express Web Server介绍的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 以太坊节点布置(4) geth节点互联
- 下一篇: MIMIC 以太坊医疗项目开发(2) 前