リクエストのJSONデータを受け取る - Bottle
from bottle import route, run, request @route("/hello") def hello(): contentType = request.get_header('Content-Type') print(f"header Content-Type: {contentType}") if contentType == "application/json": pprint(request.json) if __name__ == "__main__": run(host="localhost", port=3000, debug=True)
request.get_header()
でheaderのContent-Typeがapplication/json
であるか確認request.json
でデータを受け取る