I have a static angular project that can run on Apache, and I want to migrate it to the node environment. I don’t know how to write node’s server.js and page.json.
阿神2017-05-15 16:57:19
Just write it like this in KOA
var koa = require('koa');
var serve = require('koa-static');
var path = require('path');
// KOA框架
var app = module.exports = koa();
// 错误处理
app.on('error', function(err, ctx){
console.log(err.message);
});
// 静态中间件
app.use(serve(path.join(__dirname, 'public')));
// 监听端口
if (!module.parent){
app.listen(3000);
logger.info('My Website run on 3000...');
}
/app.js
/public/index.html //angular entrance
世界只因有你2017-05-15 16:57:19
Use nokit, one line of command:
$ cd <angular项目目录>
$ nokit start <port> -public:./
For more detailed usage, check http://nokit.org
習慣沉默2017-05-15 16:57:19
Put it directly in the static file. After use, just access the static page address directly. This is how this game works
http://tianmaying.com/app/collect-b/index.html
为情所困2017-05-15 16:57:19
Hey, try sero-cli. The second item is "Start a static web server for current working directory". Use this command in the root directory of your angular project. Just select the second item.