python - Airfow 提供静态 html 目录
问题描述
我在以下位置使用 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"
)
推荐阅读
- html - 粘性页脚重叠正文内容?
- javascript - 如何在javascript中更改滚动时的背景颜色
- c# - 通过点击列表视图中的其他按钮更改按钮的图像,查看单元格
- javascript - winnhttp 资源未加载 - 无法通过表标签名称抓取
- ios - Unmute Video player on volume up button even mute switch is down like Snapchat video player
- webgl - p5.js problem with png alpha in webgl mode
- python - Jupyter notebook : kernel died msg when loading big CSV file
- node.js - Error getting document ReferenceError: from_data is not defined
- c# - WPF dynamically create formula in TextBox
- python - 为什么在 python 3.5.2 中比较相同的 dict 值会返回 False?