Added support for specifying hostname for the --server command

Fixes #301
print-window-tiddler
Jermolene 2013-12-29 13:07:06 +00:00
rodzic 4cdfbd6b36
commit bd7db62da0
2 zmienionych plików z 9 dodań i 7 usunięć

Wyświetl plik

@ -79,7 +79,7 @@ SimpleServer.prototype.checkCredentials = function(request,incomingUsername,inco
}
}
SimpleServer.prototype.listen = function(port) {
SimpleServer.prototype.listen = function(port,host) {
var self = this;
http.createServer(function(request,response) {
// Compose the state object
@ -125,7 +125,7 @@ SimpleServer.prototype.listen = function(port) {
});
break;
}
}).listen(port);
}).listen(port,host);
};
var Command = function(params,commander,callback) {
@ -264,7 +264,8 @@ Command.prototype.execute = function() {
renderType = this.params[2] || "text/plain",
serveType = this.params[3] || "text/html",
username = this.params[4],
password = this.params[5];
password = this.params[5],
host = this.params[6];
this.server.set({
rootTiddler: rootTiddler,
renderType: renderType,
@ -272,8 +273,8 @@ Command.prototype.execute = function() {
username: username,
password: password
});
this.server.listen(port);
console.log("Serving on port " + port);
this.server.listen(port,host);
console.log("Serving on " + host + ":" + port);
console.log("(press ctrl-C to exit)");
return null;
};

Wyświetl plik

@ -1,5 +1,5 @@
created: 20131219163923630
modified: 20131222150651114
modified: 20131229130513478
tags: command
title: ServerCommand
type: text/vnd.tiddlywiki
@ -9,7 +9,7 @@ The server built in to TiddlyWiki5 is very simple. Although compatible with Tidd
At the root, it serves a rendering of a specified tiddler. Away from the root, it serves individual tiddlers encoded in JSON, and supports the basic HTTP operations for `GET`, `PUT` and `DELETE`.
```
--server <port> <roottiddler> <rendertype> <servetype> <username>
--server <port> <roottiddler> <rendertype> <servetype> <username> <password> <host>
```
The parameters are:
@ -20,6 +20,7 @@ The parameters are:
* ''servetype'' - the content type with which the root tiddler should be served (defaults to "text/html")
* ''username'' - the default username for signing edits
* ''password'' - optional password for basic authentication
* ''host'' - optional hostname to serve from (defaults to "0.0.0.0")
If the password parameter is specified then the browser will prompt the user for the username and password. Note that the password is transmitted in plain text so this implementation isn't suitable for general use.