├── server.js ├── page2.html ├── index.html ├── package.json ├── LICENSE ├── .gitignore ├── README.md └── CODE_OF_CONDUCT.md /server.js: -------------------------------------------------------------------------------- 1 | // Import and run the Express Node web server framework 2 | var express = require('express'); 3 | var app = express(); 4 | 5 | // Point it to the current directory as a static server 6 | app.use(express.static('.')); 7 | 8 | // Listen on port 3000 for any traffic 9 | app.listen(3000); 10 | -------------------------------------------------------------------------------- /page2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |15 | Back to Hello World 16 |
17 | 18 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |15 | Go to Page 2. 16 |
17 | 18 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nw-local-server", 3 | "version": "1.0.0", 4 | "description": "An example of using a local webserver in NW.js", 5 | "repository": "https://github.com/nwutils/nw-local-server-example", 6 | "node-main": "server.js", 7 | "main": "http://localhost:3000", 8 | "node-remote": "http://localhost:3000", 9 | "scripts": { 10 | "start": "nw .", 11 | "postinstall": "npx base-volta-off-of-nwjs@latest" 12 | }, 13 | "keywords": [ 14 | "NW.js", 15 | "server", 16 | "example" 17 | ], 18 | "author": "The Jared Wilcurt", 19 | "license": "MIT", 20 | "devDependencies": { 21 | "nw": "0.55.0-sdk" 22 | }, 23 | "dependencies": { 24 | "express": "^4.21.0" 25 | }, 26 | "volta": { 27 | "node": "16.4.2" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 The Jared Wilcurt 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | build/ 61 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nw-local-server 2 | 3 | An example of using a local webserver in NW.js 4 | 5 | 6 | ## How to run 7 | 8 | 1. Install [Node.js](http://nodejs.org) & npm (comes with Node) 9 | 1. Download or clone the repo 10 | 1. `npm install` 11 | 1. `npm start` 12 | 13 | 14 | ## How this works 15 | 16 | 1. `npm install` will download NW.js and Express to the `node_modules` folder. 17 | 1. `npm start` will Launch NW.js from your project's root. 18 | 1. NW.js will look at the `package.json` and see the `"node-main"` set to `server.js`. This will be the first thing NW.js runs and it runs this script in the "Node context" before a window is loaded. 19 | 1. The `server.js` runs and starts up an Express server on port 3000. 20 | 1. Next NW.js will look at the `package.json` and see the `"main"` set to `http://localhost:3000`. The `main` is usually set to `index.html`, it tells NW.js what is the first page to load for your app's UI. Since the Express server is already running NW.js will go to that URL and Express will return the `index.html` file. 21 | 1. The last step that NW.js does is look at the `package.json` and see the `"node-remote"` set to `http://localhost:3000`. The `node-remote` tells NW.js what URL's are allowed to run Node.js commands. With it pointing to the server you just started, your app can now run properly, accessing Node directly from the DOM. 22 | 1. From this point on you can create your app like you would in a regular browser. You can create folders for you images, styles, and scripts and link to them from your `index.html`. You can also access any Node modules you've installed in the project. 23 | 24 | 25 | * * * 26 | 27 | 28 | For a more detailed step-by-step tutorial of using NW.js to create your first desktop app, click here: 29 | 30 | * [Laptop Battery NW.js App Tutorial](https://gitlab.com/TheJaredWilcurt/battery-app-workshop) 31 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # "No Ideologies" Code of Conduct 2 | 3 | The following are the guidelines we expect our community members and maintainers to follow. 4 | 5 | * * * 6 | 7 | ## Terminology and Scope 8 | 9 | **What defines a "maintainer"?** 10 | 11 | * A maintainer is anyone that interacts with the community on behalf of this project. Amount of code written is not a qualifier. A maintainer may include those who solely help in support roles such as in resolving issues, improving documentation, administrating or moderating forums/chatrooms, or any other non-coding specific roles. Maintainers also include those that are responsible for the building and upkeep of the project. 12 | 13 | **What defines a "community member"?** 14 | 15 | * Anyone interacting with this project directly, including maintainers. 16 | 17 | **What is the scope of these guidelines?** 18 | 19 | * These guidelines apply only to this project and forms of communication directly related to it, such as issue trackers, forums, chatrooms, and in person events specific to this project. If a member is violating these guidelines outside of this project or on other platforms, that is beyond our scope and any grievances should be handled on those platforms. 20 | 21 | **Discussing the guidelines:** 22 | 23 | * Discussions around these guidelines, improving, updating, or altering them, is permitted so long as the discussions do not violate any existing guidelines. 24 | 25 | * * * 26 | 27 | ## Guidelines 28 | 29 | ### Guidelines for community members 30 | 31 | This project is technical in nature and not based around any particular non-technical ideology. As such, communication that is based primarily around ideologies unrelated to the technologies used by this repository are not permitted. 32 | 33 | Any discussion or communication that is primarily focused around an ideology, be it about race, gender, politics, religion, or anything else non-technical, is not allowed. Everyone has their own ideological preferences, beliefs, and opinions. We do not seek to marginalize, exclude, or judge anyone for their ideologies. To prevent conflict between those with differing or opposing ideologies, all communication on these subjects are prohibited. Some discussions around these topics may be important, however this project is not the proper channel for these discussions. 34 | 35 | ### Guidelines for maintainers 36 | 37 | * Maintainers must abide by the same rules as all other community members mentioned above. However, in addition, maintainers are held to a higher standard, explained below. 38 | * Maintainers should answer all questions politely. 39 | * If someone is upset or angry about something, it's probably because it's difficult to use, so thank them for bringing it to your attention and address ways to solve the problem. Maintainers should focus on the content of the message, and not on how it was delivered. 40 | * A maintainer should seek to update members when an issue they brought up is resolved. 41 | 42 | * * * 43 | 44 | ## Appropriate response to violations 45 | 46 | How to respond to a community member or maintainer violating a guideline. 47 | 48 | 1. If an issue is created that violates a guideline a maintainer should close and lock the issue, explaining "This issue is in violation of our code of conduct. Please review it before posting again." with a link to this document. 49 | 1. If a member repeatedly violates the guidelines established in this document, they should be politely warned that continuing to violate the rules may result in being banned from the community. This means revoking access and support to interactions relating directly to the project (issue trackers, chatrooms, forums, in person events, etc.). However, they may continue to use the technology in accordance with its license. 50 | 1. If a maintainer is in violation of a guideline, they should be informed of such with a link to this document. If additional actions are required of the maintainer but not taken, then other maintainers should be informed of these inactions. 51 | 1. If a maintainer repeatedly violates the guidelines established in this document, they should be politely warned that continuing to violate the rules may result in being banned from the community. This means revoking access and support to interactions relating directly to the project (issue trackers, chatrooms, forums, in person events, etc.). However, they may continue to use the technology in accordance with its license. In addition, future contributions to this project may be ignored as well. 52 | 53 | * * * 54 | 55 | Based on version 1.0.3 from https://github.com/CodifiedConduct/coc-no-ideologies 56 | --------------------------------------------------------------------------------