zoukankan      html  css  js  c++  java
  • Run ionic web app in nodejs

    首先需要express插件:sudo npm install express

    将ionic project的www拷贝至wwwroot,新建server.js:

    var express = require('express'),
        // employees = require('./routes/employees'),
        app = express();
     
    app.use(express.static('www'));
     
    // CORS (Cross-Origin Resource Sharing) headers to support Cross-site HTTP requests
    app.all('*', function(req, res, next) {
        res.header("Access-Control-Allow-Origin", "*");
        res.header("Access-Control-Allow-Headers", "X-Requested-With");
        next();
    });
     
    app.get('/', function (request, response) {
        response.sendFile(__dirname + "/www/index.html");
    });
     
    app.set('port', process.env.PORT || 5000);
     
    app.listen(app.get('port'), function () {
        console.log('Express server listening on port ' + app.get('port'));
    });

    then: node server 
  • 相关阅读:
    vertical-align
    剑指offer刷题
    ES6 promise
    wangyi准备
    spring定时器
    xshell下linux常用操作
    HSSFWorkbook生成excel文件
    梳理并分解继承体系
    JSON格式数据转换
    部署项目
  • 原文地址:https://www.cnblogs.com/sban/p/4634122.html
Copyright © 2011-2022 走看看