-
Notifications
You must be signed in to change notification settings - Fork 4
/
flask_code2DFD.py
40 lines (26 loc) · 1.03 KB
/
flask_code2DFD.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
from flask import Flask, jsonify, request
import code2DFD
app = Flask(__name__, instance_relative_config = True)
@app.get('/')
def index():
index_message = ("API for DFD extraction. \
Provide a GitHub URL to endpoint /dfd as parameter \"url\" to receive the extracted DFD: \
/dfd?url=https://github.com/georgwittberger/apache-spring-boot \
-microservice-example; \
Optionally provide a commit hash as \"commit\" parameter")
return index_message
@app.get('/dfd')
def dfd():
url = request.args.get("url")
commit = request.args.get("commit", None)
if not url:
return "Please specify a URL, e.g. /dfd?url=https://github.com/georgwittberger/apache-spring-boot" \
"-microservice-example "
# Call Code2DFD
results = code2DFD.api_invocation(url, commit)
# Create response JSON object and return it
response = jsonify(**results)
return response
# starts local server
if __name__ == '__main__':
app.run(debug=True, host='127.0.0.1', port=5001)