Airlfow服务静态html目录

时间:2019-06-05 13:51:43

标签: python flask airflow

我有使用sphinx构建的静态html文档:

$AIRFLOW_HOME/plugins/docs/

我想在Airflow UI中创建一个新的菜单链接“我的文档”,这样可以正常工作:

class DocsView(BaseView):
    @expose("/")
    def my_docs(self):
        return send_from_directory(os.path.abspath("plugins/docs/build/html"), 'index.html')

docs_view = DocsView(
    category="My Documentation",
    name="Plugins",
    endpoint="my_docs"
)

在我的自定义插件类中:

class MyPlugin(AirflowPlugin):
    admin_views = [docs_view]

该链接已成功显示在菜单栏中,并且仅适用于index.html。我不使用模板,只需要可以阅读所有自定义代码文档的部分。

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。我必须在 DocsView 中添加静态url和文件夹路径,因为sphinx在 build / html 中创建了其他目录:

http://169.254.169.254/metadata/instance
相关问题