-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
64 lines (50 loc) · 1.79 KB
/
run.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
import dash
from dash import Dash, _dash_renderer
import json
from flask import jsonify
from components.appshell import create_appshell
import dash_mantine_components as dmc
import os
_dash_renderer._set_react_version("18.2.0")
stylesheets = [
"https://unpkg.com/@mantine/dates@7/styles.css",
"https://unpkg.com/@mantine/charts@7/styles.css",
"https://unpkg.com/@mantine/carousel@7/styles.css",
"https://unpkg.com/@mantine/notifications@7/styles.css",
"https://unpkg.com/@mantine/nprogress@7/styles.css",
'https://cdn.jsdelivr.net/npm/[email protected]/dist/summernote.min.css',
"https://use.fontawesome.com/releases/v6.2.1/css/all.css",
]
scripts = [
"https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.10.8/dayjs.min.js",
"https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.10.8/locale/ru.min.js",
"https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.10.8/locale/fr.min.js",
"https://unpkg.com/hotkeys-js/dist/hotkeys.min.js",
]
app = Dash(
__name__,
suppress_callback_exceptions=True,
use_pages=True,
external_scripts=scripts,
external_stylesheets=stylesheets + dmc.styles.ALL,
update_title=None,
prevent_initial_callbacks=True,
index_string=open('templates/index.html').read(),
assets_folder="assets"
)
# Load data from JSON files
data = []
for i in range(6):
with open(f'data/overview_{i}.json') as f:
data.append(json.load(f))
data_dict = {i: data[i] for i in range(6)}
app.layout = create_appshell(dash.page_registry.values())
server = app.server
@app.server.route('/zoom-in/<date>', methods=['GET'])
def zoom_in(date):
# Parse the date
date = int(date)
# Return the data corresponding to the date
return jsonify(data_dict[date])
if __name__ == "__main__":
app.run_server(debug=False, host='0.0.0.0', port='8552')