On 11.12.2016 09:02, Daniel Sun wrote:
Hi all,

       Does Groovy provide any function like Python's SimpleHTTPServer(e.g.
python -m SimpleHTTPServer 8000)?  If no similar module exits, I'd like to
implement one via Groovy 3(e.g. groovy -m SimpleHTTPServer 8000).

       FYI: https://docs.python.org/2/library/simplehttpserver.html

something like:

import org.apache.catalina.startup.Tomcat
import groovy.servlet.GroovyServlet

new Tomcat().with {
    port = 8000
    ctx = addContext("", new File(".").getAbsolutePath())
    Tomcat.addServlet(ctx, "Groovy", new GroovyServlet())
    ctx.addServletMappingDecoded("/*", "Groovy")
    start()
    server.await()
}

would do the job I think... didn´t test it and the servlet-api stuff could get in the way.

If all you want is Groovy listening on a port and evaluate the scripts you give it, that is something we have already. So the question to be answered would be... what do you intend to do with the http server?

bye Jochen

Reply via email to