From 45948315dfbc63db6aeec41a23d91b831ef2bcb8 Mon Sep 17 00:00:00 2001 From: qiaolongfei Date: Fri, 24 Nov 2017 13:58:53 +0800 Subject: [PATCH] support default path --- bin/visual_dl.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/bin/visual_dl.py b/bin/visual_dl.py index 8c0e261e..22b1bca0 100644 --- a/bin/visual_dl.py +++ b/bin/visual_dl.py @@ -2,15 +2,14 @@ """ import json import os +import sys from optparse import OptionParser -from flask import send_from_directory -from flask import Flask -from flask import request +from flask import Flask, redirect +from flask import send_from_directory from visualdl.log import logger - app = Flask(__name__, static_url_path="") @@ -46,21 +45,24 @@ def gen_result(status, msg): result['data'] = {} return result -@app.route('/') -def root(): - return app.send_static_file('index.html') -@app.route('/js/') +server_path = os.path.abspath(os.path.dirname(sys.argv[0])) +static_file_path = "../visualdl/frontend/dist/" + + +@app.route('/static/') def serve_static(filename): - root_dir = os.path.dirname(os.getcwd()) - return send_from_directory(os.path.join('.', 'dist'), filename) + print("aaa") + return send_from_directory(os.path.join(server_path, static_file_path), filename) -@app.route('/hello') + +@app.route("/") def index(): - """ + return redirect('/static/index.html', code=302) - :return: - """ + +@app.route('/hello') +def hello(): result = gen_result(0, "Hello, this is VisualDL!") return json.dumps(result) -- GitLab