-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
46 lines (39 loc) · 1.43 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from flask import Flask, render_template, request, jsonify
from script import run
app = Flask(__name__)
app.config['JSON_SORT_KEYS'] = False
@app.route('/')
def index():
return jsonify({
"status": "ok"
})
# Insert new repository to database
@app.route('/insert', methods=["POST"])
def insert_repository():
if request.method == "POST":
try:
if not "owner" in request.json:
return jsonify({
"error": "É necessário que seja informado no body o dono do repositório a ser inserido!"
})
if not "repository" in request.json:
return jsonify({
"error": "É necessário que seja informado no body o nome do repositório a ser inserido!"
})
# if not "tokens" in request.json:
# return jsonify({
# "error": "É necessário que seja informada no body uma lista de tokens para correta execução da ferramenta!"
# })
owner = request.json["owner"]
repository = request.json["repository"]
# tokens = request.json["tokens"]
run(owner, repository)
return jsonify({
"success": True
})
except Exception as e:
return jsonify({
"error": e
})
if __name__ == '__main__':
app.run(host='0.0.0.0', threaded=True, port=5000)