|
|
|
@ -116,29 +116,10 @@ def search(): |
|
|
|
def webhook(): |
|
|
|
def webhook(): |
|
|
|
if request.method == 'POST': |
|
|
|
if request.method == 'POST': |
|
|
|
repo_path = "http://git.tdtdt.net:3003/zvevqx/tdtdt.git" # Replace with the actual path |
|
|
|
repo_path = "http://git.tdtdt.net:3003/zvevqx/tdtdt.git" # Replace with the actual path |
|
|
|
subprocess.run(['git', 'pull origin o2switch', repo_path]) |
|
|
|
subprocess.run(['git', 'pull', repo_path]) |
|
|
|
return "Webhook received!" |
|
|
|
return "Webhook received!" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# # Verify the secret (if you used one in Gitea) |
|
|
|
|
|
|
|
# secret = "salut" # Replace with your actual secret |
|
|
|
|
|
|
|
# if secret: |
|
|
|
|
|
|
|
# if 'X-Gitea-Signature' not in request.headers: |
|
|
|
|
|
|
|
# return "Unauthorized", 401 |
|
|
|
|
|
|
|
# received_signature = request.headers['X-Gitea-Signature'] |
|
|
|
|
|
|
|
# expected_signature = f"sha256={compute_signature(request.data, secret)}" |
|
|
|
|
|
|
|
# if received_signature != expected_signature: |
|
|
|
|
|
|
|
# return "Unauthorized", 401 |
|
|
|
|
|
|
|
# |
|
|
|
|
|
|
|
# # Perform Git pull to update the website's code |
|
|
|
|
|
|
|
# # repo_path = "/path/to/your/website/repo" # Replace with the actual path |
|
|
|
|
|
|
|
# # subprocess.run(['git', 'pull'], cwd=repo_path) |
|
|
|
|
|
|
|
# # Restart the Flask app |
|
|
|
|
|
|
|
# #restart_flask_app() |
|
|
|
|
|
|
|
# print("YOLOLYOYLOOLLYYYOOOLLOO il y a un push") |
|
|
|
|
|
|
|
# return "Webhook received and processed successfully", 200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def compute_signature(data, secret): |
|
|
|
def compute_signature(data, secret): |
|
|
|
import hmac |
|
|
|
import hmac |
|
|
|
import hashlib |
|
|
|
import hashlib |
|
|
|
|