瀏覽代碼

added CLI util

master
mortie 6 年之前
父節點
當前提交
3a020d1825
共有 3 個檔案被更改,包括 27 行新增1 行删除
  1. 7
    0
      README.md
  2. 16
    0
      cli.js
  3. 4
    1
      package.json

+ 7
- 0
README.md 查看文件

@@ -17,6 +17,13 @@ var webframe = require("webframe");
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.

## Why a new web framework?

+ 16
- 0
cli.js 查看文件

@@ -0,0 +1,16 @@
#!/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));

+ 4
- 1
package.json 查看文件

@@ -1,6 +1,6 @@
{
"name": "webframe",
"version": "0.5.0",
"version": "0.6.0",
"description": "Web framework.",
"main": "index.js",
"scripts": {
@@ -10,6 +10,9 @@
"type": "git",
"url": "https://git.mort.coffee/mort/webframe"
},
"bin": {
"webframe": "cli.js"
},
"author": "Martin Dørum <martid0311@gmail.com> (http://mort.coffee)",
"license": "ISC"
}

Loading…
取消
儲存