> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sevalla.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Flask - Health checks

> Discover how to integrate health checks into your Flask app in Sevalla.

To support zero-downtime deployments, configure a health check endpoint in your Flask application. This endpoint allows Sevalla to verify that your app is running correctly before routing traffic to it.

There are multiple ways to implement a health check in Flask, depending on the level of control and visibility required.

## Option 1: Use an existing view

If you don’t want to add a separate health check route, you can reuse an existing public view in your application. The selected view should fail with an error if a critical dependency, such as the database or another essential service, is unavailable.

## Option 2: Use a dedicated health check view

A dedicated health check route provides a clear and explicit way to verify your app’s health. A simple implementation can execute a lightweight query like `session.execute(text("SELECT 1"))` to confirm the database is reachable. If the connection fails, an exception will be raised, and the route will return an error.

```python theme={null}
from sqlalchemy import text

from .extensions import db

@app.route("/health_check")
def health_check():
    with db.sessionmaker() as session:
        session.execute(text("SELECT 1"))
    return "OK"
```

You can extend this route with additional checks (such as cache or queue connectivity) as your application grows.

## Option 3: Use a health check library

Several libraries can help you implement comprehensive health checks for databases, task queues, caches, email services, and more. One such option is [**Healthcheck**](https://github.com/ateliedocodigo/py-healthcheck), which simplifies defining and managing these checks in a single place.
