diff web/src/luan/modules/web/web_run.luan @ 283:b669cdaf54b7

add URL post; add Http.request.query_string; add web_run.form(); git-svn-id: https://luan-java.googlecode.com/svn/trunk@284 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Tue, 02 Dec 2014 03:34:04 +0000
parents 82a3ebcfbafa
children 582e8db4cdb6
line wrap: on
line diff
--- a/web/src/luan/modules/web/web_run.luan	Wed Nov 26 22:25:09 2014 +0000
+++ b/web/src/luan/modules/web/web_run.luan	Tue Dec 02 03:34:04 2014 +0000
@@ -18,13 +18,31 @@
 	end
 end
 
+local function form() %>
+<html>
+<body>
+<form action="run" method="post">
+<input type="hidden" name="content_type" value="text/plain" />
+<input type="submit" value="Execute Luan code below">
+<br />
+<textarea name="code" rows="30" cols="90" wrap="off">
+</textarea>
+</form>
+</body>
+</html>
+<% end
+
 function service()
+	Io.stdout = Http.response.text_writer()
+	local code = Http.request.parameters.code
+	if code == nil then
+		form()
+		return
+	end
 	local content_type = Http.request.parameters.content_type
 	if content_type ~= nil then
 		Http.response.content_type = content_type
 	end
-	Io.stdout = Http.response.text_writer()
-	local code = Http.request.parameters.code
 	local env = {
 		request = Http.request;
 		response = Http.response;