Skip to content

Instantly share code, notes, and snippets.

@tyama
Forked from ksky/httpd.groovy
Created March 16, 2010 17:17
Show Gist options
  • Save tyama/334247 to your computer and use it in GitHub Desktop.
Save tyama/334247 to your computer and use it in GitHub Desktop.
@Grab('org.eclipse.jetty:jetty-server:7.0.1.v20091125')
@Grab('org.eclipse.jetty:jetty-servlet:7.0.1.v20091125')
import org.eclipse.jetty.server.*
import org.eclipse.jetty.server.handler.*
import org.eclipse.jetty.servlet.*
import groovy.servlet.*
server = new Server(8080)
servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS)
servletHandler.with {
resourceBase = '.'
contextPath = '/'
addServlet(GroovyServlet, '*.groovy')
addServlet(TemplateServlet, '*.gtpl')
}
resourceHandler = new ResourceHandler(
resourceBase:".", welcomeFiles:['index.html'], directoriesListed:true)
server.handler = new HandlerList(handlers:[servletHandler, resourceHandler])
server.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment