changeset 1242:ce3279ef1bd9

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 25 Jun 2018 19:34:52 -0600
parents 2b5046cd7963
children 3ffc7c4a3b85
files src/luan/Luan.java src/luan/modules/http/Server.luan
diffstat 2 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/luan/Luan.java	Thu Jun 21 22:30:13 2018 -0600
+++ b/src/luan/Luan.java	Mon Jun 25 19:34:52 2018 -0600
@@ -15,9 +15,13 @@
 public final class Luan {
 
 	public static void main(String[] args) throws LuanException {
+		doFile( "classpath:luan/cmd_line.luan", args );
+	}
+
+	public static void doFile(String uri,String... args) throws LuanException {
 		LuanState luan = new LuanState();
-		LuanFunction standalone = (LuanFunction)BasicLuan.load_file(luan,"classpath:luan/cmd_line.luan");
-		standalone.call(luan,args);
+		LuanFunction fn = (LuanFunction)BasicLuan.load_file(luan,uri);
+		fn.call(luan,args);
 	}
 
 	public static Object first(Object obj) {
--- a/src/luan/modules/http/Server.luan	Thu Jun 21 22:30:13 2018 -0600
+++ b/src/luan/modules/http/Server.luan	Mon Jun 25 19:34:52 2018 -0600
@@ -29,8 +29,6 @@
 
 local Server = {}
 
-Server.port = 8080
-
 function Server.init_dir(dir)
 	local dir_uri, dir_path
 	if matches(dir,":") then
@@ -68,7 +66,8 @@
 	Thread.fork(Rpc.serve)
 end
 
-function Server.serve(dir)
+function Server.serve(dir,port)
+	port = port or 8080
 	local dir_path = Server.init_dir(dir)
 	local file_handler = FileHandler.new(dir_path)
 	local dir_handler = DirHandler.new(file_handler)
@@ -80,7 +79,7 @@
 	handler = ContentTypeHandler.new(handler)
 	handler = SafeHandler.new(handler)
 	handler = LogHandler.new(handler)
-	Server.server = JavaServer.new(Server.port,handler)
+	Server.server = JavaServer.new(port,handler)
 	Server.start()
 	Server.start_rpc()
 end