diff --git a/_docs/index.html b/_docs/index.html index 10679f3f..3e9754eb 100644 --- a/_docs/index.html +++ b/_docs/index.html @@ -23,18 +23,16 @@ // basepath: '../docs/', // Search Support - // search: { - // maxAge: 43200000, // 过期时间,单位毫秒,默认一天 - // paths: 'auto', - // placeholder: { - // '/en/': 'Search', - // '/': '搜索', - // }, - // noData: { - // '/en/': 'No Results', - // '/': '找不到结果', - // }, - // }, + search: { + maxAge: 43200000, // 过期时间,单位毫秒,默认一天 + paths: 'auto', + placeholder: { + '/': '搜索文档...', + }, + noData: { + '/': '找不到结果', + }, + }, // load sidebar from _sidebar.md loadSidebar: '_sidebar', @@ -46,5 +44,6 @@ } + diff --git a/server.py b/server.py index 7302d2ad..c6d279ff 100644 --- a/server.py +++ b/server.py @@ -24,7 +24,7 @@ except: p("需要flask才可使用本服务。\n安装方式:%s install flask" % ("pip3" if isPy3 else "pip")) exit(1) -app = Flask(__name__, static_folder='') +app = Flask(__name__, static_folder='__static__') app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0 @app.after_request @@ -45,7 +45,7 @@ def get_mimetype(path): return mimetypes.guess_type(path)[0] or 'application/octet-stream' def get_file(path): - if not os.path.exists(path): + if not os.path.isfile(path): abort(404) return None if not is_sub(path): @@ -61,6 +61,12 @@ def root(): @app.route('/', methods=['GET']) def static_file(path): + if os.path.isdir(path): + if not path.endswith('/'): path += '/' + path += 'index.html' + if not os.path.isfile(path): + abort(404) + return None return Response(get_file(path), mimetype = get_mimetype(path)) def process_request():