我有一个Flask应用程序,我正在通过pythonsphinx构建文档。在
我当前正在使用来自sphinxcontrib.autohttp.flask
的autoflask扩展
我的问题是:如何准备一个docstring,它将不同的信息正确地应用于同一路由的GET版本和POST版本。在
例如一个小函数:
@app.route('/add_event', methods=['GET', 'POST'])
def add_event():
"""
..http:get:: /add_event
:return: Test
..http:post:: /add_event
:return: Test2
"""
if request.method == 'GET':
# get some things
person_id = request.args.get('id')
return render_template('create_event.html', race_event_form=test_form)
if request.method == 'POST':
# post some things
return redirect('/person_profile/id/{0}'.format(request.args.get('id')))
我当前的扩展配置文件在
^{pr2}$斯芬克斯的输出看起来像
有没有可能对一件事做一件事,另一件事做一个职位?我真的希望避免将每个函数拆分为两个单独的get/post函数。在
另外,是否可以通过request.args
或request.form
传递autoflask output所需的参数,就像GET请求中的person_id
变量一样?在
尝试从Flask autodoc中删除重载的view函数,并单独定义请求,同时让API的其余部分自动生成。在
这里有个例子。。。在
在
conf.py
(插件的顺序是重要的):在RestructedText文件中:
^{pr2}$关于第二个问题,您可以查看
httpdomain
here的指令。在相关问题 更多 >
编程相关推荐