天天看點

建立一個tornado項目的記錄(2):首頁

1.設定首頁可以在route ‘/’ 所在的 handler中設定redirect

2.需要在web主類中設定JinjaLoader和smartStaticFileHandler

loader = JinjaLoader(loader=ChoiceLoader([
            FileSystemLoader(os.path.join(self_dir_path, 'templates')),
        ]), debug=options.debug)
SmartStaticFileHandler.file_finder = MultiFileFindler(
            [],
            os.path.join(self_dir_path, 'static'))

        routes = get_main_routes()
           

3.根據上面的設定,建立static 和 template包,分别放靜态檔案(js、css等)以及html檔案

繼續閱讀