提交 45948315 编写于 作者: Q qiaolongfei

support default path

上级 972f7447
...@@ -2,15 +2,14 @@ ...@@ -2,15 +2,14 @@
""" """
import json import json
import os import os
import sys
from optparse import OptionParser from optparse import OptionParser
from flask import send_from_directory
from flask import Flask from flask import Flask, redirect
from flask import request from flask import send_from_directory
from visualdl.log import logger from visualdl.log import logger
app = Flask(__name__, static_url_path="") app = Flask(__name__, static_url_path="")
...@@ -46,21 +45,24 @@ def gen_result(status, msg): ...@@ -46,21 +45,24 @@ def gen_result(status, msg):
result['data'] = {} result['data'] = {}
return result return result
@app.route('/')
def root():
return app.send_static_file('index.html')
@app.route('/js/<path:filename>') server_path = os.path.abspath(os.path.dirname(sys.argv[0]))
static_file_path = "../visualdl/frontend/dist/"
@app.route('/static/<path:filename>')
def serve_static(filename): def serve_static(filename):
root_dir = os.path.dirname(os.getcwd()) print("aaa")
return send_from_directory(os.path.join('.', 'dist'), filename) return send_from_directory(os.path.join(server_path, static_file_path), filename)
@app.route('/hello')
@app.route("/")
def index(): def index():
""" return redirect('/static/index.html', code=302)
:return:
""" @app.route('/hello')
def hello():
result = gen_result(0, "Hello, this is VisualDL!") result = gen_result(0, "Hello, this is VisualDL!")
return json.dumps(result) return json.dumps(result)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册