1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-11-08 19:43:34 +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; var self = this;
http.createServer(function(request,response) { http.createServer(function(request,response) {
// Compose the state object // Compose the state object
@@ -125,7 +125,7 @@ SimpleServer.prototype.listen = function(port) {
}); });
break; break;
} }
}).listen(port); }).listen(port,host);
}; };
var Command = function(params,commander,callback) { var Command = function(params,commander,callback) {
@@ -264,7 +264,8 @@ Command.prototype.execute = function() {
renderType = this.params[2] || "text/plain", renderType = this.params[2] || "text/plain",
serveType = this.params[3] || "text/html", serveType = this.params[3] || "text/html",
username = this.params[4], username = this.params[4],
password = this.params[5]; password = this.params[5],
host = this.params[6];
this.server.set({ this.server.set({
rootTiddler: rootTiddler, rootTiddler: rootTiddler,
renderType: renderType, renderType: renderType,
@@ -272,8 +273,8 @@ Command.prototype.execute = function() {
username: username, username: username,
password: password password: password
}); });
this.server.listen(port); this.server.listen(port,host);
console.log("Serving on port " + port); console.log("Serving on " + host + ":" + port);
console.log("(press ctrl-C to exit)"); console.log("(press ctrl-C to exit)");
return null; return null;
}; };

View File

@@ -1,5 +1,5 @@
created: 20131219163923630 created: 20131219163923630
modified: 20131222150651114 modified: 20131229130513478
tags: command tags: command
title: ServerCommand title: ServerCommand
type: text/vnd.tiddlywiki 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`. 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: 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") * ''servetype'' - the content type with which the root tiddler should be served (defaults to "text/html")
* ''username'' - the default username for signing edits * ''username'' - the default username for signing edits
* ''password'' - optional password for basic authentication * ''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. 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.