问题
I have created a Airflow plugin which creates a new Menu named Test Plugin and add a submenu Test View so clicking the Test View open the page successfully and show me the content in test.html page.
Currently Airflow displays the landing page on the url http://localhost:8080/admin/ with all Dags listed.
My requirement is to show this test.html page as the landing page/home page.
The structure of is as follows:
-AIRFLOW_HOME/plugins/templates/test_plugin/test.html
-AIRFLOW_HOME/plugins/test_view.py
The code from test_view.py is as follows:
from airflow.plugins_manager import AirflowPlugin
from flask import Blueprint
from flask_admin import BaseView, expose
from flask_admin.base import MenuLink
class TestView(BaseView):
@expose('/')
def test(self):
return self.render("test_plugin/test.html", content="Hello galaxy!")
v = TestView(category="Test Plugin", name="Test View")
blue_print_ = Blueprint("test_plugin",
__name__,
template_folder='templates',
static_folder='static',
static_url_path='/static/test_plugin')
class AirflowTestPlugin(AirflowPlugin):
name = "test_plugin"
flask_blueprints = [blue_print_]
admin_views = [v]
来源:https://stackoverflow.com/questions/60864142/override-airflows-default-admin-index-page