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" version = "0.1"
from flask import Flask from flask import Flask
from flask_restx import Resource, Api
app = Flask(__name__) 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 uuid
import inspect import inspect
import redis import redis
r = redis.Redis(host='127.0.0.1', port='3033') r = redis.Redis(host='127.0.0.1', port='3033')
@app.route('/info') @api.route('/info')
def info(): class info(Resource):
def get(self):
return "CyCAT backend {}".format(version) return "CyCAT backend {}".format(version)
@app.route('/generate/uuid') @api.route('/generate/uuid')
def generateUUID(): class generateUUID(Resource):
def get(self):
genuuid = uuid.uuid4() genuuid = uuid.uuid4()
k = "stats:f:{}".format(inspect.stack()[0][3].lower()) k = "stats:f:{}".format(inspect.stack()[0][3].lower())
r.incr(k, 1) r.incr(k, 1)

View File

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