我有一个flask应用程序,我想使用Sphinx的autoflask指令来记录flask restfulapi。在
https://pythonhosted.org/sphinxcontrib-httpdomain/#module-sphinxcontrib.autohttp.flask
我已经通过pip安装了这个模块,并运行了sphinx快速启动,这给了我一个配置文件以及索引.rst. 在
我试过把分机放进配置文件公司名称:
extensions = ['sphinxcontrib.autohttp.flask']
指令进入索引.rst根据文件:
^{pr2}$但我拿不到应用程序:模块(自动烧瓶_示例应用程序:应用程序)零件正确。结果,当我运行sphinx build时,我得到一个错误消息:要么找不到应用程序,要么找不到模块。在
我的应用程序树如下所示:
.
├── admin
├── apis
├── app
│ ├── static
│ └── templates
从应用程序的根目录,我可以说:
from apis import profile
如何在中配置自动烧瓶索引.rst正确查找并加载我的应用程序的API模块?在
我的代码结构,在哪里应用程序.py使用flask app文件,我运行我的服务器python应用程序.py运行服务器
在配置文件你应该包括扩展和abs路径到你应用程序.py在你的任何一个主应用程序中。在
^{pr2}$在你可以使用蓝图之后,从你的flask应用程序查看视图
换句话说,在运行makehtml之前,应该通过python sys path将abs path添加到根应用程序文件夹中系统路径插入(0,操作系统路径.abspath('/home/myproject/)),其中包含源代码的/home/myproject文件夹。在
相关问题 更多 >
编程相关推荐