From 972f7447fee15f00c45ef30f30d03cddbeb70fc3 Mon Sep 17 00:00:00 2001 From: qiaolongfei Date: Fri, 24 Nov 2017 10:37:07 +0800 Subject: [PATCH] add serve static files --- bin/visual_dl.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/bin/visual_dl.py b/bin/visual_dl.py index 3efef160..8c0e261e 100644 --- a/bin/visual_dl.py +++ b/bin/visual_dl.py @@ -1,14 +1,17 @@ """ entry point of visual_dl """ import json +import os from optparse import OptionParser +from flask import send_from_directory from flask import Flask from flask import request from visualdl.log import logger -app = Flask(__name__) + +app = Flask(__name__, static_url_path="") def option_parser(): @@ -43,8 +46,16 @@ def gen_result(status, msg): result['data'] = {} return result - @app.route('/') +def root(): + return app.send_static_file('index.html') + +@app.route('/js/') +def serve_static(filename): + root_dir = os.path.dirname(os.getcwd()) + return send_from_directory(os.path.join('.', 'dist'), filename) + +@app.route('/hello') def index(): """ -- GitLab