Skip to content

Commit 95dba07

Browse files
committed
update
1 parent de2492b commit 95dba07

File tree

5 files changed

+26
-11
lines changed

5 files changed

+26
-11
lines changed

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ a weather dashboard built from OpenWeatherMaps APi, MongoDB, and Plotly Dash
55
todo:
66

77
- add weather codes to heatmap: https://openweathermap.org/weather-conditions
8-
- add automatic refresh with callbacks
9-
- add sunset/sunrise
8+
- fix app title

app.py

+18-9
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import dash_html_components as html
1010
import plotly.express as px
1111
import plotly.graph_objs as go
12+
from dash.dependencies import Input, Output
1213
import plotly.figure_factory as ff
1314
import pandas as pd
1415
import numpy as np
@@ -25,6 +26,7 @@
2526
PORT = CONFIG["DB_PORT"]
2627
NAME = CONFIG["DB_NAME"]
2728
INTERVAL = CONFIG["INTERVAL"]
29+
SERVER_PORT = CONFIG["PORT"]
2830

2931
mc = MongoClient(host=HOST, port=PORT)
3032
cw = mc[NAME].weather_current
@@ -59,6 +61,7 @@
5961
"tornado": 30
6062
}
6163

64+
app = dash.Dash(__name__, title="wdash", update_title="wdash")
6265

6366

6467
def convert_meteorological_deg2cardinal_dir(deg_measurement):
@@ -404,8 +407,12 @@ def wind_direction_graph(df_wind, history_rgb, forecast_rgb):
404407
)
405408
return fig
406409

407-
408-
def generate_page():
410+
@app.callback(
411+
Output(component_id='all_info', component_property="children"),
412+
Input(component_id="interval", component_property="n_intervals")
413+
)
414+
def generate_page(n_intervals):
415+
logging.info(f"Regenerating info div: times regenerated = {n_intervals}")
409416
df = create_df()
410417

411418
fig_temp = create_time_figure(
@@ -634,11 +641,12 @@ def generate_page():
634641
y=df_square_ints.index.tolist(),
635642
x=df_square_ints.columns.tolist(),
636643
annotation_text=df_square_statuses.values,
637-
colorscale="Viridis",
644+
colorscale="Turbo",
638645
showscale=False,
639646
customdata=df_square_statuses.values,
640647
hovertemplate="forecast:%{customdata}",
641-
name="Forecast"
648+
name="Forecast",
649+
font_colors=["white", "black"],
642650
)
643651
figh.update_layout(
644652
template="plotly_dark",
@@ -682,8 +690,8 @@ def generate_page():
682690

683691

684692

685-
app = dash.Dash(__name__, title="wdash", update_title="wdash")
686-
app.title = "wdash"
693+
694+
687695

688696
app.layout = html.Div(
689697
children=[
@@ -693,15 +701,16 @@ def generate_page():
693701
Updated with data from the OpenWeatherMaps API, pyOWM, and Windy.
694702
''', style={"color": "white"}),
695703
html.Br(),
696-
generate_page(),
704+
html.Div(id="all_info"),
697705

698706
],
699707
style={"backgroundColor": "rgb(17,17,17)"}
700708
)
701-
709+
app.title = "wdash"
702710

703711
if __name__ == '__main__':
704712
pd.set_option('display.max_rows', 500)
705713
pd.set_option('display.max_columns', 500)
706714
pd.set_option('display.width', 1000)
707-
app.run_server(debug=True)
715+
# app.run_server(debug=True, port=SERVER_PORT)
716+
app.run_server(debug=False, host="0.0.0.0", port=SERVER_PORT)

config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ DB_HOST: "localhost"
44
DB_PORT: 27017
55
DB_NAME: "wdash"
66
INTERVAL: 1800
7+
PORT: 57042
78
# Your api key goes here
89
API_KEY: ""

kill.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Warning! This assumes your only bg processes are those started by run.py
2+
3+
kill %1
4+
kill %2

run.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
python daemon.py &
2+
python app.py &

0 commit comments

Comments
 (0)