-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.py
88 lines (76 loc) · 2.05 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import logging
from logging.config import dictConfig
import click
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
from keysersoze.apps.app import APP
from keysersoze.apps import portfolio
from keysersoze.apps.asset_page import generate_asset_page
LOGGER = logging.getLogger(__name__)
dictConfig({
'version': 1,
'formatters': {
'simple': {
'format': '%(asctime)s - %(filename)s:%(lineno)s: %(message)s',
}
},
'handlers': {
'default': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple',
"stream": "ext://sys.stdout",
},
},
'loggers': {
'__main__': {
'handlers': ['default'],
'level': 'DEBUG',
'propagate': True
},
'keysersoze': {
'handlers': ['default'],
'level': 'DEBUG',
'propagate': True
}
}
})
LOGO = APP.get_asset_url('logo.png')
APP.title = '投资账户概览'
APP.layout = html.Div(
[
dcc.Location(id='url', refresh=False),
html.Link(
rel='stylesheet',
href=APP.get_asset_url('css/style.css'),
),
html.Div(id='page-content')
],
style={
'padding-top': 20,
'padding-left': '10%',
'padding-right': '10%',
},
)
@APP.callback(
Output('page-content', 'children'),
Input('url', 'pathname')
)
def display_page(pathname):
if pathname in ('/portfolio', '/'):
APP.title = '投资账户概览'
return portfolio.layout
elif pathname.startswith('/asset/'):
asset_code = pathname.replace('/asset/', '').strip('/')
layout = generate_asset_page(asset_code)
return layout
else:
return '404'
@click.command()
@click.option("--port", type=int, default=8050)
@click.option("--debug", is_flag=True)
def main(port, debug):
APP.run_server(host='0.0.0.0', port=port, debug=debug)
if __name__ == '__main__':
main()