added python files
This commit is contained in:
parent
50f393c8af
commit
db0e793651
|
@ -0,0 +1,22 @@
|
|||
from flask import Flask, request
|
||||
import subprocess
|
||||
import json
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/webhook', methods=['POST'])
|
||||
def webhook():
|
||||
# Check if the received webhook is from Git
|
||||
if request.headers.get('X-GitHub-Event') == 'push':
|
||||
# Pull the latest changes from Git
|
||||
subprocess.run(['git', 'pull'])
|
||||
|
||||
# Restart the example_app
|
||||
subprocess.run(['systemctl', 'stop', 'restart_this_app.service'])
|
||||
|
||||
return 'Success!', 200
|
||||
else:
|
||||
return 'Invalid webhook event.', 400
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host='0.0.0.0', port=5001)
|
|
@ -0,0 +1,14 @@
|
|||
from flask import Flask, request
|
||||
import json
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/restart-this-app')
|
||||
def funky_function():
|
||||
data = { 'message': "Hello World!" }
|
||||
response = json.dumps(data)
|
||||
|
||||
return response, 200, { 'Content-Type': 'application/json' }
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host='0.0.0.0', port=5002)
|
Loading…
Reference in New Issue