summary refs log tree commit diff stats
path: root/rod/webrepl.nim
diff options
context:
space:
mode:
authorrumpf_a@web.de <>2010-01-10 17:53:33 +0100
committerrumpf_a@web.de <>2010-01-10 17:53:33 +0100
commit55e900bba2be06cf91789e749d9fc31f017a0dd0 (patch)
tree6e223c8a7c3f70767b036d698de7ed00a2f80ea3 /rod/webrepl.nim
parenta4ba67dd2eb335cb9c41a6a267b774a4830ea529 (diff)
downloadNim-55e900bba2be06cf91789e749d9fc31f017a0dd0.tar.gz
devel of web frontend
Diffstat (limited to 'rod/webrepl.nim')
-rw-r--r--rod/webrepl.nim71
1 files changed, 71 insertions, 0 deletions
diff --git a/rod/webrepl.nim b/rod/webrepl.nim
new file mode 100644
index 000000000..bf59bbfec
--- /dev/null
+++ b/rod/webrepl.nim
@@ -0,0 +1,71 @@
+#
+#
+#           The Nimrod Compiler
+#        (c) Copyright 2010 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Creates a server, opens a browser and starts serving a Repl for the user.
+## Unfortunately it doesn't ever stop...
+
+import httpserver, sockets, browsers, strutils, cgi, options
+
+const
+  gui = """
+<html>  
+  <head>
+    <title>Nimrod Interactive Web Console</title>
+  </head>
+  
+  <body>
+    <form action="exec" method="get">
+      <input type="submit" value="Run" /><br />
+      <textarea name="code" cols="80" rows="30">import strutils, os
+
+# your code here</textarea>
+      <table border="0">
+        <tr>
+          <td><input type="checkbox" name="objChecks" checked="true"
+               value="on">objChecks</input></td>
+          <td><input type="checkbox" name="fieldChecks" checked="true"
+               value="on">fieldChecks</input></td>
+          <td><input type="checkbox" name="rangeChecks" checked="true"
+               value="on">rangeChecks</input></td>
+        </tr><tr>
+          <td><input type="checkbox" name="boundChecks" checked="true"
+               value="on">boundChecks</input></td>
+          <td><input type="checkbox" name="overflowChecks" checked="true"
+               value="on">overflowChecks</input></td>
+          <td><input type="checkbox" name="nanChecks" checked="true"
+               value="on">nanChecks</input></td>
+        </tr><tr>
+          <td><input type="checkbox" name="infChecks" checked="true"
+               value="on">infChecks</input></td>
+          <td><input type="checkbox" name="assertions" checked="true"
+               value="on">assertions</input></td>
+        </tr>
+      </table>
+    </form>
+    $1
+  </body>
+</html>
+"""
+
+proc runCode(input: string): string =
+  nil
+
+proc handleRequest(client: TSocket, path, query: string) =
+  var output = query
+  client.send(gui % output & wwwNL)
+
+
+var s: TServer
+open(s, TPort(0))
+browsers.openDefaultBrowser("http://localhost:" & $s.port)
+while true: 
+  next(s)
+  handleRequest(s.client, s.path, s.query)
+  close(s.client)
+close(s)