Override Airflow's default admin index page

此生再无相见时 提交于 2021-02-11 16:49:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!