MIMIC 以太坊醫療專案開發(1) Express Web Server介紹
阿新 • • 發佈:2021-02-13
技術標籤:MIMIC以太坊醫療專案
Express 是一個很小規模的靈活的 Node.js Web 應用程式開發框架,為 Web 和移動應用程式提供一組強大的功能。使用 Express 可以快速地搭建一個完整功能的網站,它提供了精簡的基本 Web 應用程式功能,而不會隱藏您瞭解和青睞的 Node.js 功能。使用 Express 可以快速地搭建一個完整功能的網站。
1. 安裝
npm install -g express –registry=https://registry.npm.taobao.org
cnpm init 生成package.json
{
“name”: “code”,
“description”: “”,
“main”: “index.js”,
“scripts”: {
“test”: “echo “Error: no test specified” && exit 1”
},
“author”: “”,
“license”: “ISC”,
“dependencies”: {
“express”: “^4.17.1”
}
}
cnpm install
cnpm install express --save
安裝命令工具
npm install -g express-generator
express --version
最好設定NODE_PATH的環境變數
2. helloworld.js示例程式碼
// 引入 e xpress 模組 var express = require('express'); // 建立 express 例項 var app = express(); // 響應HTTP的GET方法 app.get('/', function (req, res) { res.send('Hello World!'); }); // 監聽到8000埠 app.listen(8000, function () { console.log('Hello World is listening at port 8000'); });
執行“node HelloExpress.js”命令,在瀏覽器輸入”localhost:8000” 則會看到: