diff -r 292b26405ee7 -r e5799432071c qmsk/web/args.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/qmsk/web/args.py Sat Jun 07 16:21:39 2014 +0300 @@ -0,0 +1,46 @@ +import werkzeug.serving +import argparse + +import logging; log = logging.getLogger('qmsk.web.args') + +def options (parser, static=None) : + """ + Command-line options. + """ + + parser = parser.add_argument_group("qmsk.web") + + parser.add_argument('--web-static', metavar='PATH', default=static, + help="Path to static files") + + parser.add_argument('--web-debug', action='store_true', + help="Web-based debugger") + + return parser + +def apply (options, application_class, *args, **opts): + """ + Build given qmsk.web.Application from options. + """ + + return application_class(*args, + **opts + ) + +def main (options, application) : + """ + Run given WSGI application via the werkzeug development server. + """ + + static_files = { } + + if options.web_static: + static_files['/static'] = options.web_static + + log.info("http://0.0.0.0:8080/") + werkzeug.serving.run_simple('0.0.0.0', 8080, application, + use_debugger = options.web_debug, + static_files = static_files, + ) + + return 0