import asyncio
import logging
from .log import logger
from .http import (HttpConnectionCB, HttpRequestCB, StaticRootResource)


def main():
    # TODO: parse commandline options
    logging.basicConfig(level=logging.DEBUG)

    loop = asyncio.get_event_loop()

    def root_factory(req):
        return StaticRootResource('.')

    req_cb = HttpRequestCB(root_factory)
    conn_cb = HttpConnectionCB(req_cb)

    starter = asyncio.start_server(conn_cb, '127.0.0.1', 8080, loop=loop)
    server = loop.run_until_complete(starter)

    logger().debug('Server serving at 127.0.0.1:8080')

    try:
        loop.run_forever()
    except KeyboardInterrupt:
        pass

    server.close()
    loop.run_until_complete(server.wait_closed())
    loop.close()


if __name__ == '__main__':
    main()

@@ -23,16 +23,32 @@
 logging%0A
+import argparse%0A
 from .lo
@@ -145,53 +145,1220 @@
 def 
-main():%0A    # TODO: parse commandline options
+_parse_arguments():%0A    parser = argparse.ArgumentParser()%0A    parser.add_argument('-r', '--root',%0A                        help='Root dir to serve (default: .)',%0A                        default='.',%0A                        type=str)%0A    parser.add_argument('-b', '--bind',%0A                        help='Specify bind address (default: all interfaces)',%0A                        default='',%0A                        type=str)%0A    parser.add_argument('-p', '--port',%0A                        help='Which port to listen (default: 8000)',%0A                        default=8000,%0A                        type=int)%0A    parser.add_argument('--backlog',%0A                        help='Backlog for the listening socket (default: 128)',%0A                        default=128,%0A                        type=int)%0A    parser.add_argument('--loglevel',%0A                        help='Log level (default: info)',%0A                        default='info',%0A                        type=str,%0A                        choices=%5B%0A                            'critical', 'fatal', 'error',%0A                            'warning', 'info', 'debug',%0A                        %5D)%0A%0A    return parser.parse_args()%0A%0A%0Adef main():%0A    args = _parse_arguments()%0A
 %0A   
@@ -1388,21 +1388,29 @@
 vel=
-logging.DEBUG
+args.loglevel.upper()
 )%0A%0A 
@@ -1506,19 +1506,25 @@
 esource(
-'.'
+args.root
 )%0A%0A    r
@@ -1647,25 +1647,85 @@
 cb, 
-'127.0.0.1', 8080
+args.bind, args.port,%0A                                   backlog=args.backlog
 , lo
@@ -1780,16 +1780,44 @@
 arter)%0A%0A
+    if args.bind == '':%0A    
     logg
@@ -1821,21 +1821,20 @@
 ogger().
-debug
+info
 ('Server
@@ -1849,23 +1849,134 @@
  at 
-127.0.0.1:8080'
+%3Call interfaces%3E:%7B%7D'.format(args.port))%0A    else:%0A        logger().info('Server serving at %7B%7D:%7B%7D'.format(args.bind, args.port)
 )%0A%0A 

Add arguments for the cmdline script