Run Node.js server file automatically after launching Electron App

前端 未结 1 2073
感动是毒
感动是毒 2020-12-28 21:17

Im using GitHub Electron to create Desktop application with web technologies.

I\'m using Node.js as the server, my problem is that i do

相关标签:
1条回答
  • 2020-12-28 21:43

    Just simply require the server.js file in your main file (e.g. app.js):

    var app = require("app")
      , server = require("./server")
      ;
    
    ...
    

    And in the server.js file you can have:

     require("http").createServer(function (req, res) {
         res.end("Hello from server started by Electron app!");
     }).listen(9000)
    
    0 讨论(0)
提交回复
热议问题