# folder
[andychung@shared-docker-builder test2]$ ls
node_modules package.json package-lock.json public server.js
#################################
# server.js
var fs = require('fs');
var host = '0.0.0.0';
var port = 8080;
var express = require('express');
const path = require('path')
var app = express();
// http://10.0.1.30/hello_vue.html
app.use(express.static(path.join(__dirname, "public")));
app.get("/", function(request, response){
response.send("hello express");
});
app.get("/a", function(request, response){
response.send(__dirname);
});
app.listen(port, host);
#################################
# package json
[andychung@shared-docker-builder test2]$ cat package.json
{
"name": "y",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.18.2"
}
}
沒有留言:
張貼留言