introduced the 'mime' config option, addresses #3
This commit is contained in:
13
README.md
13
README.md
@ -56,7 +56,7 @@ Server
|
|||||||
-p, --port <number> Web server port
|
-p, --port <number> Web server port
|
||||||
-f, --log-format <string> If a format is supplied an access log is written to stdout. If not,
|
-f, --log-format <string> If a format is supplied an access log is written to stdout. If not,
|
||||||
a statistics view is displayed. Use a preset ('none', 'dev',
|
a statistics view is displayed. Use a preset ('none', 'dev',
|
||||||
'default', 'short', 'tiny' or 'logstalgia') or supply a custom format
|
'combined', 'short', 'tiny' or 'logstalgia') or supply a custom format
|
||||||
(e.g. ':method -> :url').
|
(e.g. ':method -> :url').
|
||||||
-d, --directory <string> Root directory, defaults to the current directory
|
-d, --directory <string> Root directory, defaults to the current directory
|
||||||
-c, --compress Enables compression
|
-c, --compress Enables compression
|
||||||
@ -144,6 +144,17 @@ To view your stored defaults, run:
|
|||||||
$ ws --config
|
$ ws --config
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##mime-types
|
||||||
|
You can set additional mime-type/extension mappings, or override the defaults by setting a `mime` value in your local config. This value is passed directly to [mime.define()](https://github.com/broofa/node-mime#mimedefine). Example:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mime": {
|
||||||
|
"text/plain": [ "php", "pl" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
##Use with Logstalgia
|
##Use with Logstalgia
|
||||||
local-web-server is compatible with [logstalgia](http://code.google.com/p/logstalgia/).
|
local-web-server is compatible with [logstalgia](http://code.google.com/p/logstalgia/).
|
||||||
|
|
||||||
|
@ -47,7 +47,8 @@ var storedConfig = loadConfig(
|
|||||||
var builtInDefaults = {
|
var builtInDefaults = {
|
||||||
port: 8000,
|
port: 8000,
|
||||||
directory: process.cwd(),
|
directory: process.cwd(),
|
||||||
"refresh-rate": 500
|
"refresh-rate": 500,
|
||||||
|
mime: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* override built-in defaults with stored config and then command line args */
|
/* override built-in defaults with stored config and then command line args */
|
||||||
@ -98,7 +99,7 @@ if (argv.Misc.config){
|
|||||||
}
|
}
|
||||||
|
|
||||||
app.use(morgan(logFormat));
|
app.use(morgan(logFormat));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if no `--log-format` was specified, pipe the default format output
|
/* if no `--log-format` was specified, pipe the default format output
|
||||||
into `log-stats`, which prints statistics to the console */
|
into `log-stats`, which prints statistics to the console */
|
||||||
@ -110,6 +111,9 @@ if (argv.Misc.config){
|
|||||||
/* --compress enables compression */
|
/* --compress enables compression */
|
||||||
if (argv.Server.compress) app.use(compress());
|
if (argv.Server.compress) app.use(compress());
|
||||||
|
|
||||||
|
/* set the mime-type overrides specified in the config */
|
||||||
|
serveStatic.mime.define(argv.Server.mime);
|
||||||
|
|
||||||
/* enable static file server, including directory browsing support */
|
/* enable static file server, including directory browsing support */
|
||||||
app.use(serveStatic(path.resolve(argv.Server.directory)))
|
app.use(serveStatic(path.resolve(argv.Server.directory)))
|
||||||
.use(directory(path.resolve(argv.Server.directory), { icons: true }));
|
.use(directory(path.resolve(argv.Server.directory), { icons: true }));
|
||||||
|
@ -8,7 +8,7 @@ module.exports = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "log-format", alias: "f", type: String,
|
name: "log-format", alias: "f", type: String,
|
||||||
description: "If a format is supplied an access log is written to stdout. If not, \na statistics view is displayed. Use a preset ('none', 'dev',\n'default', 'short', 'tiny' or 'logstalgia') or supply a custom format\n(e.g. ':method -> :url')."
|
description: "If a format is supplied an access log is written to stdout. If not, \na statistics view is displayed. Use a preset ('none', 'dev',\n'combined', 'short', 'tiny' or 'logstalgia') or supply a custom format\n(e.g. ':method -> :url')."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "directory", alias: "d", type: String,
|
name: "directory", alias: "d", type: String,
|
||||||
|
@ -26,5 +26,10 @@
|
|||||||
"serve-static": "^1.2.2",
|
"serve-static": "^1.2.2",
|
||||||
"stream-log-stats": "^0.1.0",
|
"stream-log-stats": "^0.1.0",
|
||||||
"typical": "^1.0.0"
|
"typical": "^1.0.0"
|
||||||
|
},
|
||||||
|
"local-web-server": {
|
||||||
|
"mime": {
|
||||||
|
"text/plain": ["php"]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
5
test/.local-web-server.json
Normal file
5
test/.local-web-server.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"mime": {
|
||||||
|
"text/plain": [ "php" ]
|
||||||
|
}
|
||||||
|
}
|
1
test/something.php
Normal file
1
test/something.php
Normal file
@ -0,0 +1 @@
|
|||||||
|
<?php echo "i'm coding PHP templatez!\n" ?>
|
Reference in New Issue
Block a user