
Building a Health Check Page in Flask: The /status Route | Python Comeback Journey #6
After learning how to pass data into templates, I wanted to build something slightly more useful than a static contact page — something that actually reports what the app is doing. That led me to the idea of a status page, a small diagnostic route that shows the app’s current state.
At first, it was just curiosity. But the process of building /status taught me something deeper: a good Flask app doesn’t just serve users — it also communicates with its developer.
🧩 Step 1: Creating the /status Route
The goal was simple: show a live status message and the current time whenever the page is loaded.
Here’s the core route I added to app.py:
|
1 2 3 4 5 |
@app.route(‘/status’) def status(): current_time = datetime.now().strftime(‘%Y-%m-%d %H:%M:%S’) return render_template(‘status.html’, status=‘OK’, message=‘Server running smoothly’, current_time=current_time) |
The route returns three variables: status, message, and current_time. Flask passes them into the template just like before.
🧱 Step 2: Building the Template
Inside templates/status.html:
|
1 2 3 4 5 6 7 8 9 10 11 12 |
{% extends “base.html” %} {% block title %}Status – Book Tracker{% endblock %} {% block content %} <p>Status: {{ status }}</p> <p>Message: {{ message }}</p> <p>Checked at: {{ current_time }}</p> <a href=“{{ url_for(‘home’) }}”>Home</a> {% endblock %} |
This page extended base.html, reused its navigation, and displayed data dynamically. The current_time variable updated every time I refreshed the page — instant feedback that the app was alive.
⚙️ Step 3: Adding Structure and Comments
I added comments in both Python and Jinja for clarity:
|
1 2 3 |
# Route: /status # Purpose: Display basic server health and timestamp |
|
1 2 3 4 5 |
{# Template: status.html Purpose: Show server state and timestamp for quick checks Extends: base.html #} |
Even though this was a small file, documenting the purpose made it easier to read later. When you revisit a project after weeks or months, those comments are a gift to your future self.
💡 Step 4: Why /status Matters
At first glance, /status is trivial — it just prints “OK.” But conceptually, it marks a shift: the app is no longer static. It reacts to time and data.
This mindset — of treating routes as dynamic data reporters — becomes the foundation for dashboards, logs, and even API endpoints.
It’s also one of the simplest ways to confirm your Flask app is working while you experiment with templates or refactor your routes. A /status route is like a heartbeat monitor: small, but reassuring.
🚀 Reflection
What I learned here wasn’t just how to display a timestamp. It was about creating feedback loops. A developer’s app should talk back, even if only through a message saying “OK.”
The next phase of the journey would move from displaying information to persisting it — taking the book data that lived inside the code and giving it a home outside the source files.
Stay tuned for Python Comeback Journey #7: Keeping Your Repo Clean — The Right .gitignore for Flask Projects.





Leave a Reply