added python files

This commit is contained in:
root 2023-05-26 00:00:06 +00:00
parent 50f393c8af
commit db0e793651
2 changed files with 36 additions and 0 deletions

22
app.py Normal file
View File

@ -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)

14
restart_this_app.py Normal file
View File

@ -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)