-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.py
More file actions
49 lines (33 loc) · 1.19 KB
/
debug.py
File metadata and controls
49 lines (33 loc) · 1.19 KB
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
47
48
49
import json
from flask import Flask
from flask import Response
from flask import Blueprint
from swagger_ui import flask_api_doc
__author__ = "Mirco Manzoni"
__credits__ = ["Mirco Manzoni"]
__status__ = "Development"
DEBUG_PREFIX = 'debug'
API_PREFIX = ''
debug_page = Blueprint(DEBUG_PREFIX, __name__)
@debug_page.route('/')
def hello():
resp = {'msg': 'This is the REST API for debugging of DUE-VDM'}
return Response(json.dumps(resp), status=200, mimetype='application/json')
@debug_page.route('/vdcs')
def get_vdcs():
resp = ['a', 'b', 'c']
return Response(json.dumps(resp), status=200, mimetype='application/json')
@debug_page.route('<string:vdc>/methods')
def get_methods(vdc):
resp = ['a', 'b', 'c']
return Response(json.dumps(resp), status=200, mimetype='application/json')
app = Flask(__name__)
app.debug = True
# API v1
app.register_blueprint(debug_page, url_prefix=API_PREFIX + '/' + DEBUG_PREFIX)
@app.route('/')
def index():
resp = {'msg': 'This is the REST API of DUE-VDM'}
return Response(json.dumps(resp), status=200, mimetype='application/json')
# Generating the docs
flask_api_doc(app, config_path='./specs.yaml', url_prefix='/api/doc', title='API doc')