jmlrt's links Shaared links 2021-02-23T08:32:20+00:00 jmlrt's links https://julien.mailleret.fr/links/ https://julien.mailleret.fr/links/ Shaarli webhook python flask · @jeekajoo links https://julien.mailleret.fr/links/shaare/S2nG0g 2017-02-07T18:46:17+00:00 2021-02-23T08:32:20+00:00

Un webhook listener en Python avec Flask pour exécuter des actions automatiquement après un push git sur GitHub ou BitBucket:

import os
from sys import platform as _platform

from flask import Flask
from flask import request
app = Flask(__name__)

@app.route('/webhook', methods=['POST'])
def tracking():
    data = request.get_json()
    commit_author = data['actor']['username']
    commit_hash = data['push']['changes'][0]['old']['target']['hash'][:7]
    commit_url = data['push']['changes'][0]['old']['target']['links']['html']['href']
    print 'Webhook received! %s committed %s: %s' % (commit_author, commit_hash, commit_url)
    return 'OK'

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000, debug=True)

(via https://jeekajoo.eu/links/?Ao6lJA)


Permalink]]>