chg: [server] move to flask-restx + OpenAPI documentation exposed

main
Alexandre Dulaunoy 2021-05-22 12:04:05 +02:00
parent 8862cfcfce
commit 8f8af42b1e
No known key found for this signature in database
GPG Key ID: 09E2CD4944E6CBCD
2 changed files with 18 additions and 10 deletions

View File

@ -1,17 +1,24 @@
version = "0.1"
from flask import Flask
from flask_restx import Resource, Api
app = Flask(__name__)
app.url_map.strict_slashes = False
api = Api(app, version=version, title='CyCAT.org API', description='CyberSecurity catalog API services', doc='/doc/')
import uuid
import inspect
import redis
r = redis.Redis(host='127.0.0.1', port='3033')
@app.route('/info')
def info():
@api.route('/info')
class info(Resource):
def get(self):
return "CyCAT backend {}".format(version)
@app.route('/generate/uuid')
def generateUUID():
@api.route('/generate/uuid')
class generateUUID(Resource):
def get(self):
genuuid = uuid.uuid4()
k = "stats:f:{}".format(inspect.stack()[0][3].lower())
r.incr(k, 1)

View File

@ -1,2 +1,3 @@
flask
redis
flask_restplus