1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-09-28 15:08:46 +00:00

Added support for specifying hostname for the --server command

Fixes #301
This commit is contained in:
Jermolene 2013-12-29 13:07:06 +00:00
parent 4cdfbd6b36
commit bd7db62da0
2 changed files with 9 additions and 7 deletions

View File

@ -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;
};

View File

@ -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.