私は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'
]
よう
に見えるが、右にそれが可能です1つはGET用、もう1つはPOST用ですか? IDは実際には、すべての関数を2つの別々のget/post関数に分割することを避けるのが好きです。
person_id
GET要求の変数のように、自動フラッシュ出力必須引数をrequest.args
またはrequest.form
に渡すことは可能ですか?
これを実行しましたか? – jfunk
私はプロジェクトから遠ざかっていませんでした:/私は新しいプロジェクトから少し時間を取ってすぐにそれを振り返ります。入力ありがとう – Busturdust