Mercurial Hosting > luan
diff web/src/luan/modules/web/web_shell.luan @ 170:7c792a328a83
add web component
git-svn-id: https://luan-java.googlecode.com/svn/trunk@171 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Sun, 22 Jun 2014 05:20:30 +0000 |
parents | src/luan/modules/web/web_shell.luan@9169581dc8fc |
children | 58c6ca5d4524 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/src/luan/modules/web/web_shell.luan Sun Jun 22 05:20:30 2014 +0000 @@ -0,0 +1,56 @@ +import "Http" + +per_session = true + +local history = {} +local env = {} + +Io.stdout = {} +function Io.stdout.write(...) + for _,v in Basic.values(...) do + history[#history+1] = v + end +end + +function page() + if Http.request.get_parameter("clear") ~= nil then + history = {} + else + local cmd = Http.request.get_parameter("cmd") + if cmd ~= nil then + print( "% "..cmd ) + try + local line = load(cmd,"<web_shell>",env,true); + Debug.print_if_something( line() ) + catch e do + Io.print_to(Io.stderr,e) + print(e) + end + end + end + + local write = Http.response.text_writer().write + write %> +<html> +<title>Luan Shell</title> + <body> + <p>This is a command shell. Enter commands below. + <pre><% + for _,v in ipairs(history) do + write(v) + end + write %></pre> + <form name='theForm' method='post'> + % <input name='cmd' size=60> + <input type=submit value=run> + <input type=submit name=clear value=clear> + </form> + + <script>document.theForm.cmd.focus();</script> + + <p/> + </body> +</html> +<% + +end