| var app = new webframe.App(); | var app = new webframe.App(); | ||||
| ``` | ``` | ||||
| Or from the command line: | |||||
| ``` Bash | |||||
| npm install -g webframe | |||||
| webframe [directory] | |||||
| ``` | |||||
| The file example.js contains an example of a small web application. | The file example.js contains an example of a small web application. | ||||
| ## Why a new web framework? | ## Why a new web framework? |
| #!/usr/bin/env node | |||||
| if (process.argv[2] === "-h" || process.argv[2] === "--help") { | |||||
| console.log("Usage: webframe [directory]"); | |||||
| console.log(" Create a web server in directory [dir] (or in the current directory).") | |||||
| console.log(" Set the port (default 8080) with the PORT environment variable."); | |||||
| console.log(" Set the host (default 127.0.0.1) with the HOSTNAME environment variable."); | |||||
| process.exit(1); | |||||
| } | |||||
| var webframe = require("."); | |||||
| var dir = process.argv[2] || "."; | |||||
| var app = new webframe.App(); | |||||
| app.get("^.*", webframe.static(dir)); |
| { | { | ||||
| "name": "webframe", | "name": "webframe", | ||||
| "version": "0.5.0", | |||||
| "version": "0.6.0", | |||||
| "description": "Web framework.", | "description": "Web framework.", | ||||
| "main": "index.js", | "main": "index.js", | ||||
| "scripts": { | "scripts": { | ||||
| "type": "git", | "type": "git", | ||||
| "url": "https://git.mort.coffee/mort/webframe" | "url": "https://git.mort.coffee/mort/webframe" | ||||
| }, | }, | ||||
| "bin": { | |||||
| "webframe": "cli.js" | |||||
| }, | |||||
| "author": "Martin Dørum <martid0311@gmail.com> (http://mort.coffee)", | "author": "Martin Dørum <martid0311@gmail.com> (http://mort.coffee)", | ||||
| "license": "ISC" | "license": "ISC" | ||||
| } | } |