//node ./service/appCore/test.js
console.log('==============================================');
console.log(' service  run');
console.log('==============================================');
const express = require('express');
const app  = express();
const swig = require('swig');
const path = require("path");
//const fs = require('fs');              //檔案讀取

//const project = JSON.parse(fs.readFileSync('./service/config/projectInfo.json', 'utf8').toString());
const project = require( "../config/projectInfo.json" );

const version = project.version;
const host = project.host;
const resource = project.resource;

console.log('--------------------------------------------');
console.log('info');
console.log('--------------------------------------------');
console.log("version  : " +version);
console.log("host     : " + host);
console.log("resource : " + resource);
console.log('');

/**----------------------------------------------
 *
 *	 __dirname   絕對路徑，目前檔案所在資料夾路徑。
 *   __filename  絕對路徑，目前檔案路徑。
 *
 *----------------------------------------------*/
console.log('--------------------------------------------');
console.log('path');
console.log('--------------------------------------------');
console.log(__dirname);
console.log(__filename);
console.log(path.normalize(__dirname+path.sep+'..'));
console.log(path.resolve('\service\\views'));
console.log(path.sep);
console.log(path.dirname(__dirname));
console.log(path.dirname(__dirname)+path.sep+'views');
console.log('');


var res_url = path.normalize(__dirname+path.sep+'..'+path.sep+'..')+path.sep+'web'+path.sep+'dist'+path.sep+version+path.sep;
console.log('--------------------------------------------');
console.log("resource path");
console.log('--------------------------------------------');
console.log(res_url);
console.log('');

//靜態資源
app.use(express.static(res_url));

// This is where all the magic happens!
app.engine('html', swig.renderFile);
app.set('view engine', 'html');
app.set('views', path.dirname(__dirname)+path.sep+'views'+path.sep+'test');	//設定views所在路徑


// Swig will cache templates for you, but you can disable
// that and use Express's caching instead, if you like:
app.set('view cache', false);
// To disable Swig's cache, do the following:
swig.setDefaults({ cache: false });
// NOTE: You should always cache templates in a production environment.
// Don't leave both of these to `false` in production!

app.get('/', function (req, res) {
  res.render('test', { title : '測試', host: host, resource : resource});
});

app.get('/test', function (req, res) {
  res.render('test', { title : '測試', host : host, resource : resource});
});

app.listen(1337);
console.log('Application Started on http://localhost:1337/');
@@ -1130,16 +1130,28 @@
 g('path'
+%09%09%09%09%09%09%09%09%09%09  
 );%0Aconso
@@ -1259,62 +1259,87 @@
 e);%0A
-console.log(path.normalize(__dirname+path.sep+'..'));%0A
+//path method test%0A//console.log(path.sep);%09%09%09%09%09%09%09%09%09%09%09// window %E7%82%BA %5C linux %E7%82%BA/%0A//
 cons
@@ -1355,60 +1355,155 @@
 ath.
-resolve('%5Cservice%5C%5Cviews'));%0Aconsole.log(path.sep);%0A
+normalize('/Users/xxx/otp/demo.js'));    %09%09// %5CUsers%5Cxxx%5Cotp%5Cdemo.js%0A//console.log(path.dirname('/Users/xxx/otp/demo.js'));%09%09%09%09// /Users/xxx/otp%0A//
 cons
@@ -1519,102 +1519,224 @@
 ath.
-dir
+base
 name(
-__dirname));%0Aconsole.log(path.dirname(__dirname)+path.sep+'views');%0Aconsole.log('');%0A%0A
+'/Users/xxx/otp/demo.js'));%09%09%09%09// demo.js%0A//console.log(path.extname('/Users/xxx/otp/demo.js'));%09%09%09%09// .js%0A//console.log(path.resolve('/Users/xxx/otp/demo.js', '../../'));%09//%5CUsers%5Cxxx   %E4%BB%A5__dirname%E7%82%BA%E4%B8%BB%EF%BC%8C%E4%BD%9C%E7%9B%B8%E5%B0%8D%E8%B7%AF%E5%BE%91%E8%A7%A3%E6%9E%90
 %0Avar
@@ -1748,23 +1748,22 @@
 url 
+%09
 = path.
-normaliz
+resolv
 e(__
@@ -1773,294 +1773,142 @@
 name
-+path.sep+'..'+path.sep+'..')+path.sep+'web'+path.sep+'
+, '../../web/
 dist
+/
 '+
-path.sep+version+path.sep;%0Aconsole.log('--------------------------------------------');%0Aconsole.log(%22resource path%22);%0Aconsole.log('--------------------------------------------');%0Aconsole.log(res_url);%0Aconsole.log('
+version+'/');%0Avar views_path%09= path.resolve(__dirname, '../views/test
 ');%0A%0A//
+%E8%A8%AD%E5%AE%9A
 %E9%9D%9C%E6%85%8B%E8%B3%87%E6%BA%90
+%E6%89%80%E5%9C%A8%E8%B7%AF%E5%BE%91  (%E5%A6%82%E8%B3%87%E6%BA%90%E7%A7%BB%E5%88%B0nginx%E6%88%96%E6%98%AFaws s3%E5%89%87%E6%AD%A4%E8%99%95%E8%A8%BB%E8%A7%A3%E6%8E%89)
 %0Aapp
@@ -2069,64 +2069,18 @@
 s', 
-path.dirname(__dirname)+path.sep+'
 views
-'+
+_
 path
-.sep+'test'
 );%09/

修正 path 用法.