Created
February 3, 2016 23:42
-
-
Save davidjb/8b96905063423e811752 to your computer and use it in GitHub Desktop.
Simple webhook endpoint for accepting requests to trigger a git update
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bottle import route, run, response, request, redirect | |
import os | |
import subprocess | |
@route('/', method="POST") | |
@route('/') | |
def main(): | |
os.chdir('/opt/example-org-pages') | |
return_code = subprocess.check_call('git pull', shell=True) | |
if return_code == 0: | |
return redirect("https://example.org", 302) | |
else: | |
return "Experienced an error: %i" % return_code | |
run(host='0.0.0.0', port=9998) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment