Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions path/to/airflow-webserver/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from flask import Flask
from .views import init_app

app = Flask(__name__)
init_app(app)
1 change: 1 addition & 0 deletions path/to/airflow-webserver/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// No changes needed
1 change: 1 addition & 0 deletions path/to/airflow-webserver/routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// No changes needed
1 change: 1 addition & 0 deletions path/to/airflow-webserver/services.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// No changes needed
21 changes: 21 additions & 0 deletions path/to/airflow-webserver/templates/dags.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% extends 'base.html' %}

{% block content %}
<h1>DAGs</h1>
<table>
<thead>
<tr>
<th>DAG ID</th>
<th>Previous Run Status</th>
</tr>
</thead>
<tbody>
{% for dag in dags %}
<tr>
<td>{{ dag.dag_id }}</td>
<td>{{ previous_runs[loop.index0]['status'] }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}
4 changes: 4 additions & 0 deletions path/to/airflow-webserver/views/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .dags import dags_blueprint

def init_app(app):
app.register_blueprint(dags_blueprint)
22 changes: 22 additions & 0 deletions path/to/airflow-webserver/views/dags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from airflow import settings
from airflow.models import DagModel
from airflow.utils import timezone
from flask import Blueprint, render_template

dags_blueprint = Blueprint('dags', __name__, template_folder='templates')

@dags_blueprint.route('/dags')
def dags():
# Get all DAGs
dags = DagModel.query.all()

# Get the status of all previous DAG runs
previous_runs = []
for dag in dags:
runs = DagModel.query.filter_by(dag_id=dag.dag_id).order_by(DagModel.run_id.desc()).all()
previous_runs.append({
'dag_id': dag.dag_id,
'status': 'success' if runs[0].state == 'success' else 'failure'
})

return render_template('dags.html', dags=dags, previous_runs=previous_runs)
Loading