File tree 4 files changed +84
-0
lines changed
4 files changed +84
-0
lines changed Original file line number Diff line number Diff line change
1
+ """ entry point of visual_dl
2
+ """
3
+ import json
4
+ from optparse import OptionParser
5
+
6
+ from flask import Flask
7
+ from flask import request
8
+
9
+ from visualdl .log import logger
10
+
11
+ app = Flask (__name__ )
12
+
13
+
14
+ def option_parser ():
15
+ """
16
+
17
+ :return:
18
+ """
19
+ parser = OptionParser (usage = "usage: visual_dl visual_dl.py " \
20
+ "-p port [options]" )
21
+ parser .add_option (
22
+ "-p" ,
23
+ "--port" ,
24
+ default = 8040 ,
25
+ action = "store" ,
26
+ dest = "port" ,
27
+ help = "rest api service port" )
28
+ return parser .parse_args ()
29
+
30
+
31
+ # return data
32
+ # status, msg, data
33
+ def gen_result (status , msg ):
34
+ """
35
+
36
+ :param status:
37
+ :param msg:
38
+ :return:
39
+ """
40
+ result = dict ()
41
+ result ['status' ] = status
42
+ result ['msg' ] = msg
43
+ result ['data' ] = {}
44
+ return result
45
+
46
+
47
+ @app .route ('/' )
48
+ def index ():
49
+ """
50
+
51
+ :return:
52
+ """
53
+ result = gen_result (0 , "Hello, this is VisualDL!" )
54
+ return json .dumps (result )
55
+
56
+
57
+ if __name__ == '__main__' :
58
+ options , args = option_parser ()
59
+ logger .info (" port=" + str (options .port ))
60
+ app .run (debug = False , host = "0.0.0.0" , port = options .port )
Original file line number Diff line number Diff line change
1
+ from setuptools import setup
2
+
3
+ setup (name = "visualdl" ,
4
+ version = "0.0.1" ,
5
+ packages = ['visualdl' ],
6
+ include_package_data = True ,
7
+ install_requires = [
8
+ 'flask>=0.12.1'
9
+ ],
10
+ url = 'http://www.baidu.com/' ,
11
+ license = 'Apache 2.0' ,
12
+ )
Original file line number Diff line number Diff line change
1
+ import log
2
+
3
+ __all__ = [
4
+ 'log'
5
+ ]
Original file line number Diff line number Diff line change
1
+ import logging
2
+
3
+ logger = logging
4
+
5
+ logger .basicConfig (
6
+ format = '[%(levelname)s %(asctime)s %(filename)s:%(lineno)s] %(message)s' )
7
+ logger .getLogger ().setLevel (logging .INFO )
You can’t perform that action at this time.
0 commit comments