-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathapp.py
76 lines (63 loc) · 2.18 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
import dash
import logging
from dash import html, dcc, Output, Input, callback, ALL
from config import CONFIG
from assets.footer import footer
from pages.nav import navbar
from utils.loading_data import load_data
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(levelname)s - %(message)s",
force=True
)
logging.info(f"Environment chosen: {CONFIG.ENV}")
app = dash.Dash(
__name__,
title='Space Exploration',
use_pages=True,
update_title=False,
suppress_callback_exceptions=True,
prevent_initial_callbacks=True,
meta_tags=[
{"name": "description", "content": "A Dash app focused on space exploration data."},
{"name": "keywords", "content": "Space, Launch, Data, Visualization, Dash,"
"NASA, SpaceX, Rocket, Satellite, Mars, Moon, Astronaut, Space Station, "
"Orbital, Galaxy, Universe, Telemetry, Spacecraft, Interstellar, Cosmonaut, "
"Astrobiology, Exoplanet, Space Shuttle, Space Mission, Space Probe, Hubble, "
"Space Tourism, Space Colony, Zero Gravity, Deep Space"}
],
)
server = app.server
app.layout = html.Div(
[
navbar(),
dcc.Store('past-launches-data'),
dcc.Store(id='past-launches-last-update'),
dash.page_container,
footer,
]
)
@callback(
Output('historical-data', 'data'),
Output('historical-facts-last-update', 'data'),
Input('historical-data', 'id'),
)
def load_historical_facts_data(_):
return load_data('HISTORICAL_FACTS_FILENAME', 'json')
@callback(
Output('past-launches-data', 'data'),
Output('past-launches-last-update', 'data'),
Input('past-launches-data', 'id'),
)
def load_past_launches_data(_):
df, last_update = load_data('PAST_LAUNCHES_FILENAME', 'csv')
return df.to_dict('records'), last_update
@callback(
Output('next-launch-data', 'data'),
Output('next-launch-last-update', 'data'),
Input('next-launch-data', 'id'),
)
def load_next_launch_data(_):
return load_data('NEXT_LAUNCH_FILENAME', 'json')
if __name__ == "__main__":
app.run_server(debug=True)