node.js - how to use node-webkit with express server? -
I am developing an app that uses nodes and express.
I want to export it as a package with node-webkit.
How can I start the server and run the app with it?
I'm working on it's self-learning here to convert an express app into a node webkit app. The basics are.
I think that you have two modules installed on a node.js app. First express.js and some other template engine I am using handlers so I will use it for this example.
The app I want to convert to you is probably the simplest possible, in short I would say that you are using Express to do two things - run a server and by one path Answers that give a view file
Step 1 Download the node WebKit: Step 2. Open it < Strong> Step 3 Open the console and the CD in the newly created folder (I will call this directory the app - transparency is out here). When you are there - run this command: when it is done: Step 4: to create two additional folders . Named Resources and other names make a file named View App-parent package.json . Copy the following code into package.json Go to the resource folder and create a file named index.html . Copy the copy of this to: App-parent and create a new file index.hbs . This file Copy the following code inside. The last step. Strong> p> App-parent strong> / strong>. Your app should launch. P> Full strong> p> div> html>
Install npm Express
Npm app-parent Express-handler
{"name": "app", "main": "resource / index Step1:
& lt ;! DOCTYPE html & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Meta charset = "UTF-8" & gt; & Lt; Title & gt; & Lt; / Title & gt; & Lt; / Head & gt; & Lt ;! --______________________________________________________ BEGIN APP - & gt; & Lt; Body & gt; & Lt; Script & gt; & Lt; / Script & gt; & Lt; Script & gt; Var Express = Required ('Express'); Var app = express (); Var expressHbs = Required ('Express-handbars'); AppEngine ('HBS', Express HBS ({extname: 'hbs'})); App.set ('visual engine', 'HBS'); App.list ("3000", function (mistake) {if (err) (f) ("/", function (req, res) {res.render ("index", {item: "weeeeeeeee"})}) {Console.log ("server is not working");} else {console.log ("working on server 3000")}}} window.location.href = 'http: // localhost: 3000' ; & Lt; / script> & lt;! --______________________________________________________ & APP -> Strong> Step 7. Go to the View folder in
& lt ;! DOCTYPE html & gt; & Lt; html> gt; Top & gt; & lt; Meta Charset = "UTF-8">
Comments
Post a Comment