Python Airlfow服务于静态html目录

Python Airlfow服务于静态html目录,python,flask,airflow,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') do

我在中使用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。我不使用模板,只需要一个可以阅读所有自定义代码文档的部分。

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

docs_view = DocsView(
    static_folder=os.path.abspath("plugins/docs/build/html"),
    static_url_path="/",
    category="My Documentation",
    name="Plugins",
    endpoint="my_docs"
)

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

docs_view = DocsView(
    static_folder=os.path.abspath("plugins/docs/build/html"),
    static_url_path="/",
    category="My Documentation",
    name="Plugins",
    endpoint="my_docs"
)