""" Website for Craftbroec RR stuff """ import os import hashlib import hmac from subprocess import call from flask import jsonify, abort, request from app import app @app.route('/') def index(): """Show index page""" return jsonify(True) @app.route('/deploy', methods=['POST']) def deploy(): """Run deploy script""" secret = os.environ["WEBHOOK_KEY"].encode('utf-8') digest = hmac.new(secret, request.data, hashlib.sha256).hexdigest() signature = request.headers['X-Gogs-Signature'] if len(signature) < 2 or not hmac.compare_digest(signature, digest): abort(400, 'Invalid signature') call(['git', 'pull']) call(['touch', 'flask.wsgi']) return jsonify(True)