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.route('/hook', methods=['POST'])
|
||||
@app.route('/push', methods=['POST', 'GET'])
|
||||
def push_hook():
|
||||
data = json.loads(request.get_data(as_text=True))
|
||||
name = data['repository']['name']
|
||||
clone_url = data['repository']['clone_url']
|
||||
with open('dest.json', 'r', encoding='utf8') as f:
|
||||
dest_dict = json.load(f)
|
||||
dest = os.path.join(dest_dict[name], f'{name}.tar.gz')
|
||||
download(name, clone_url, dest)
|
||||
return jsonify({'msg': 'ok'})
|
||||
data = request.get_json()
|
||||
path = request.args.get('path')
|
||||
name = data.get('repository').get('name')
|
||||
if not all([path, name]):
|
||||
return jsonify({'code': 0})
|
||||
|
||||
|
||||
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}')
|
||||
return jsonify({'code': 0, 'name': name, 'path': path})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
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