[TIL]Flask-routerとmethod
フラスコルーティングの使用方法
from flask import jsonify, redirect, url_for
@app.route('/test/name/<name>')
def name(name):
return f"name is {name},{escape(type(name))}"
@app.route('/test/id/<int:id>')
def id(id):
return 'Id: %d' % id
@app.route('/test/path/<path:subpath>')
def path(subpath):
return subpath
@app.route('/test/json')
def json():
return jsonify({'hello':'world'})
@app.route('/test/redirect/<path:subpath>')
def redirect_url(subpath):
return redirect(subpath)
@app.route('/test/urlfor/<path:subpath>')
def urlfor(subpath):
return redirect(url_for('path',subpath=subpath))
フラスコの使い方from flask import request
@app.route('/test/method/<id>', methods=['GET','POST'])
def method(id):
return jsonify({
'request.args':request.args,
'request.form':request.form,
'request.json':request.json,
'request.method':request.method
})
Reference
この問題について([TIL]Flask-routerとmethod), 我々は、より多くの情報をここで見つけました https://velog.io/@devjakeh/TIL-Flask-routerテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol