#
#
# 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 = """
Nimrod Interactive Web Console
$1
"""
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)