1
我有一個Flask應用程序,我正在爲通過python-sphinx構建文檔。Sphinx Autoflask - 區分相同功能的GET和POST請求的文檔字符串
我目前使用從sphinxcontrib.autohttp.flask
的autoflask擴展我的問題是:我如何可以準備一個文檔字符串,其正確適用不同的信息相同路線的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')))
我在conf.py電流擴展
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.ifconfig',
'sphinx.ext.viewcode',
'sphinx.ext.githubpages',
'sphinxcontrib.httpdomain',
'sphinxcontrib.autohttp.flask',
'sphinxcontrib.autohttp.flaskqref'
]
獅身人面像輸出看起來像
是否有可能向右一個GET和另一個POST的一件事?我真的很想避免將每個函數分成兩個單獨的get/post函數。
另外,是否有可能在GET請求中自動輸入通過或request.form
所需的自變量,如person_id
變量?
你有沒有解決這個問題? – jfunk
我沒有,離開這個項目:/我很快回頭看看它,當我從新項目中抽出一些時間。感謝您的輸入 – Busturdust