Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
""" This is a simple stupid script to startup ModJy inside of an embedded Jetty server. Tested with Jython 2.5.1 and Jetty Hightide 6.1H.18 Example invocation: jython jetty_run.py --port 8080 --app_dir myapp There should be a WSGI application in: myapp/application.py Source listing of myapp/application.py: 1 def handler(environ, start_response): 2 status = '200 OK' 3 response_headers = [('Content-type','text/plain')] 4 start_response(status, response_headers) 5 return ['Hello world!\n'] """ from org.mortbay.jetty import Server from org.mortbay.jetty.servlet import Context from org.mortbay.jetty.servlet import ServletHolder from com.xhaus.modjy import ModjyJServlet from java.util import Properties import argparse parser = argparse.ArgumentParser(description="Startup the webtools") parser.add_argument('--port', type=int, required=True) parser.add_argument('--app_dir', type=str, required=True) args = parser.parse_args() props = Properties() props.setProperty('app_directory', args.app_dir) server = Server(args.port) root = Context(server,"/",Context.SESSIONS) root.setInitParams(props) root.addServlet(ServletHolder(ModjyJServlet()), "/*") server.start()
This paste will be private.
From the Design Piracy series on my blog: