Skip to content

Instantly share code, notes, and snippets.

@davidjb
Created February 3, 2016 23:42
Show Gist options
  • Save davidjb/8b96905063423e811752 to your computer and use it in GitHub Desktop.
Save davidjb/8b96905063423e811752 to your computer and use it in GitHub Desktop.
Simple webhook endpoint for accepting requests to trigger a git update
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