forked from MichaelKarpe/dash-text-mining-dashboard
/
index.py
63 lines (51 loc) · 1.75 KB
/
index.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
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import callbacks # NOQA
from app import app, server # NOQA
from layouts import build_layout, noPage
from mining import lexical_field_to_url_name
app.index_string = """
<!DOCTYPE html>
<html>
<head>
{%metas%}
<title>Small talk benchmark</title>
{%favicon%}
{%css%}
</head>
<body>
{%app_entry%}
<footer>
{%config%}
{%scripts%}
{%renderer%}
</footer>
<div>Small talk benchmark</div>
</body>
</html>
"""
app.layout = html.Div([dcc.Location(id="url", refresh=False), html.Div(id="page-content")])
# Update page callback
@app.callback(Output("page-content", "children"), [Input("url", "pathname")])
def display_page(pathname):
"""Update the lexicon page to display."""
if pathname in ["/"] + [url_name for url_name in lexical_field_to_url_name.values()]:
return build_layout(pathname)
else:
return noPage
external_css = [
"https://cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.min.css",
"https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css",
"//fonts.googleapis.com/css?family=Raleway:400,300,600",
"https://codepen.io/bcd/pen/KQrXdb.css",
"https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css",
"https://codepen.io/dmcomfort/pen/JzdzEZ.css",
]
for css in external_css:
app.css.append_css({"external_url": css})
external_js = ["https://code.jquery.com/jquery-3.2.1.min.js", "https://codepen.io/bcd/pen/YaXojL.js"]
for js in external_js:
app.scripts.append_script({"external_url": js})
if __name__ == "__main__":
app.run_server(debug=False)