如何解决为什么页面不显示在气流中?
我刚刚开始学习Airflow的插件。我想制作一个测试页,我使用了文档中的代码:
from airflow.plugins_manager import AirflowPlugin
from flask import Blueprint
from flask_admin import BaseView,expose
from flask_admin.base import MenuLink
# Importing base classes that we need to derive
from airflow.hooks.base_hook import BaseHook
from airflow.models import BaseOperator
from airflow.executors.base_executor import BaseExecutor
# Will show up under airflow.macros.test_plugin.plugin_macro
def plugin_macro():
pass
# Creating a flask admin BaseView
class TestView(BaseView):
@expose('/test_plugin')
def test(self):
# in this example,put your test_plugin/test.html template at airflow/plugins/templates/test_plugin/test.html
return self.render("test_plugin/test.html",content="Hello galaxy!")
v = TestView(category="Test Plugin",name="Test View")
# Creating a flask blueprint to intergrate the templates and static folder
bp = Blueprint(
"test_plugin",__name__,template_folder='templates',# registers airflow/plugins/templates as a Jinja template folder
static_folder='static',static_url_path='/static/test_plugin')
ml = MenuLink(
category='Test Plugin',name='Test Menu Link',url='http://pythonhosted.org/airflow/')
# Defining the plugin class
class AirflowTestPlugin(AirflowPlugin):
name = "test_plugin"
macros = [plugin_macro]
admin_views = [v]
flask_blueprints = [bp]
menu_links = [ml]
文件夹结构:
airflow
|_plugins
|_templates
| |_test_plugin
| |_test.html
|_static
| |_test_plugin
|
|_test_plugin
|_test_plugin.py
我转到“ http:// someurl / test_plugin”并获取404。如何在代码中正确指定url并获取页面?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。