One possible approach would be to add the logic directly in you Dash app, i.e. something like
import dash
import dash_html_components as html
import datetime
def the_actual_layout():
return html.Div("Hello world!")
def layout():
hour = datetime.datetime.now().hour
# If we are outside business hours, return an error message.
if(hour < 8 or hour > 19):
return html.Div("The app is only available between 08:00 and 20:00, please come back tomorrow.")
# Otherwise, render the app.
return the_actual_layout()
app = dash.Dash()
app.layout = layout
if __name__ == '__main__':
app.run_server()
which would thus eliminate the need for external tools to start/stop the app.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…