diff --git a/README.md b/README.md index 23062a3cda899da287ecdfa458e163bbd807fc4d..badb87f50505646d82021fd2ab6e4ad7916d3cb3 100644 --- a/README.md +++ b/README.md @@ -1 +1,22 @@ -# VisualDL \ No newline at end of file +# VisualDL + + +### How to use +#### Step 1: build and install Python package +```shell +python setup.py bdist_wheel +cd dist +pip install visualdl-0.0.1-py2-none-any.whl +``` + +#### Step 2: build frontend +```shell +cd visualdl/frontend +npm install +npm run build +``` + +### Step 3: run +``` +python bin/visual_dl.py --port=8888 +``` \ No newline at end of file diff --git a/bin/visual_dl.py b/bin/visual_dl.py index 3efef160cbc8561bdac0e01307c9975f8194c4c6..2a286cc7e12cb51e7dcf3f80d03548f0be40ae24 100644 --- a/bin/visual_dl.py +++ b/bin/visual_dl.py @@ -1,14 +1,16 @@ """ entry point of visual_dl """ import json +import os +import sys from optparse import OptionParser -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__) +app = Flask(__name__, static_url_path="") def option_parser(): @@ -44,12 +46,22 @@ def gen_result(status, msg): return result -@app.route('/') +server_path = os.path.abspath(os.path.dirname(sys.argv[0])) +static_file_path = "../visualdl/frontend/dist/" + + +@app.route('/static/') +def serve_static(filename): + return send_from_directory(os.path.join(server_path, static_file_path), filename) + + +@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)