#!/usr/bin/env python3
# -*- coding:utf-8 -*-
import argparse

import tornado.ioloop
from tornado.web import StaticFileHandler


class NonCacheStaticFileHandler(StaticFileHandler):
    def __init__(self, *args, **kwargs):
        super(NonCacheStaticFileHandler, self).__init__(*args, **kwargs)

    def get(self, *args, **kwargs):
        super(NonCacheStaticFileHandler, self).get(*args, **kwargs)

    def set_extra_headers(self, path):
        self.set_header('Cache-control', 'no-store, no-cache, must-revalidate, max-age=0')


class Application(object):
    def __init__(self, opts):
        self._opts = opts
        self._app = self._create()

    def _create(self):
        application = tornado.web.Application([
            (r'/(favicon.ico)', StaticFileHandler, {'path': ''}),
            (r'/(.+)', NonCacheStaticFileHandler, {
                'path': self._opts.path
            }),
        ])
        return application

    def print_opts(self):
        import os
        print('Path = {0} ({1})'.format(self._opts.path, os.path.abspath(self._opts.path)))
        print('Serving HTTP on port {0} ....'.format(self._opts.port))

    def listen(self):
        self.print_opts()
        self._app.listen(self._opts.port)


def parse_arguments():
    parser = argparse.ArgumentParser(description='Simple HTTP Server with Tornado')
    parser.add_argument('-p', '--port',
                        type=int,
                        default=8888)
    parser.add_argument('path',
                        nargs='?',
                        default='.')
    return parser.parse_args()


if __name__ == '__main__':
    opts = parse_arguments()
    Application(opts).listen()
    try:
        tornado.ioloop.IOLoop.instance().start()
    except KeyboardInterrupt:
        tornado.ioloop.IOLoop.instance().stop()
        print('\nKeyboard interrupt received, Quit.')

@@ -54,16 +54,26 @@
 argparse
+%0Aimport os
 %0A%0Aimport
@@ -196,148 +196,36 @@
 def 
-__init__(self, *args, **kwargs):%0A        super(NonCacheStaticFileHandler, self).__init__(*args, **kwargs)%0A%0A    def get(self, *args, **kwargs
+set_extra_headers(self, path
 ):%0A 
@@ -274,38 +274,8 @@
 lf).
-get(*args, **kwargs)%0A%0A    def 
 set_
@@ -284,36 +284,29 @@
 tra_headers(
-self, 
 path)
-:
 %0A        sel
@@ -334,16 +334,40 @@
 ontrol',
+%0A                       
  'no-sto
@@ -689,9 +689,9 @@
 '/(.
-+
+*
 )', 
@@ -758,16 +758,67 @@
 pts.path
+,%0A                'default_filename': 'index.html',
 %0A       
@@ -895,26 +895,8 @@
 f):%0A
-        import os%0A
     
@@ -947,16 +947,56 @@
 ts.path,
+%0A                                       
  os.path
@@ -1247,16 +1247,25 @@
 tParser(
+%0A        
 descript
@@ -1301,16 +1301,21 @@
 Tornado'
+%0A    
 )%0A    pa

set index.html as default filename.