1
This commit is contained in:
parent
fafdbdee24
commit
95ce15622b
24
main.py
24
main.py
@ -5,25 +5,17 @@ from flask import Flask, request, json, jsonify
|
|||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/hook', methods=['POST'])
|
@app.route('/push', methods=['POST', 'GET'])
|
||||||
def push_hook():
|
def push_hook():
|
||||||
data = json.loads(request.get_data(as_text=True))
|
data = request.get_json()
|
||||||
name = data['repository']['name']
|
path = request.args.get('path')
|
||||||
clone_url = data['repository']['clone_url']
|
name = data.get('repository').get('name')
|
||||||
with open('dest.json', 'r', encoding='utf8') as f:
|
if not all([path, name]):
|
||||||
dest_dict = json.load(f)
|
return jsonify({'code': 0})
|
||||||
dest = os.path.join(dest_dict[name], f'{name}.tar.gz')
|
|
||||||
download(name, clone_url, dest)
|
|
||||||
return jsonify({'msg': 'ok'})
|
|
||||||
|
|
||||||
|
return jsonify({'code': 0, 'name': name, 'path': path})
|
||||||
def download(name, clone_url, dest):
|
|
||||||
os.system(f'rm -rf /tmp/{name}')
|
|
||||||
os.system(f'git clone {clone_url} /tmp/{name}')
|
|
||||||
os.system(f'cd /tmp && tar -czvf {dest} {name} ')
|
|
||||||
os.system(f'rm -rf /tmp/{name}')
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print(__name__)
|
print(__name__)
|
||||||
app.run(host='0.0.0.0', port=5000)
|
app.run(host='0.0.0.0', port=5003)
|
||||||
|
Loading…
Reference in New Issue
Block a user