Healthcheck endpoint

How can i create a custom endpoint, e.g. ‘/ping’ to return 200 on get request for a readiness probe check?

I tried to use the flask_restful and specify the class with get response like in flask_restful docs

app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])

api = Api(app)

class TodoList(Resource):
    def get(self):
        return "{status: ok}"

api.add_resource(TodoList, '/todos')

But i get this error::

File "app.py", line 395, in <module>
    api = Api(app)

AttributeError: 'Dash' object has no attribute 'handle_exception

The reason i need this is because i have the ‘Simple Auth’ setup which invokes the alert input box for authentication and this causes the 401 response when probed from terminal.
So i want to define a custom, unprotected endpoint which would respond with 200 when pinged.

Thanks

import dash
import dash_html_components as html

app = dash.Dash(__name__)

app.layout = html.Div([
    html.P("Hello World")
])

@app.server.route("/ping")
def ping():
  return "{status: ok}"

if __name__ == '__main__':
    app.run_server(host='0.0.0.0')