POSTリクエストの処理 - Bottle
POSTリクエストの処理
BottleでPOSTのリクエストを処理する場合、@route("/example", method="POST")
か@post("/example")
とすればよい
例
以下のようなwebhook.py
というソースコードがあったとする
from bottle import route, run @route('/webhook', method="POST") def webhook(): print("webhook!") run(host='localhost', port=3000, debug=True)
実行する
$ python webhook.py
http:/localhost:3000/webhook
に対してPOST送信すると
webhook! 127.0.0.1 - - [16/Aug/2017 21:27:55] "POST /webhook HTTP/1.1" 200 0
といったように出力される!