Mercurial Hosting > luan
comparison src/luan/tools/web_shell.luan @ 139:3b384dc5ca91
replace WebShell.java with web_shell.luan
git-svn-id: https://luan-java.googlecode.com/svn/trunk@140 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Fri, 13 Jun 2014 12:26:44 +0000 |
parents | |
children | f4ce03ff6b2f |
comparison
equal
deleted
inserted
replaced
138:06159094b802 | 139:3b384dc5ca91 |
---|---|
1 import "Http" | |
2 | |
3 local history = {} | |
4 | |
5 Io.stdout = {} | |
6 function Io.stdout.write(...) | |
7 for _,v in Basic.values(...) do | |
8 history[#history+1] = v | |
9 end | |
10 end | |
11 | |
12 function page() | |
13 if Http.request.get_parameter("clear") ~= nil then | |
14 history = {} | |
15 else | |
16 local cmd = Http.request.get_parameter("cmd") | |
17 if cmd ~= nil then | |
18 print( "% "..cmd ) | |
19 try | |
20 local line = load(cmd,"<web_shell>",true,true); | |
21 Debug.print_if_something( line() ) | |
22 catch e do | |
23 Io.print_to(Io.stderr,e) | |
24 print(e) | |
25 end | |
26 end | |
27 end | |
28 | |
29 local write = Http.response.text_writer().write | |
30 write %> | |
31 <html> | |
32 <title>Luan Shell</title> | |
33 <body> | |
34 <p>This is a command shell. Enter commands below. | |
35 <pre><% | |
36 for _,v in ipairs(history) do | |
37 write(v) | |
38 end | |
39 write %></pre> | |
40 <form name='theForm' method='post'> | |
41 % <input name='cmd' size=60> | |
42 <input type=submit value=run> | |
43 <input type=submit name=clear value=clear> | |
44 </form> | |
45 | |
46 <script>document.theForm.cmd.focus();</script> | |
47 | |
48 <p/> | |
49 </body> | |
50 </html> | |
51 <% | |
52 | |
53 end |