chg: [api] add a basic /propose endpoint to gather proposal

main
Alexandre Dulaunoy 2021-05-29 23:15:33 +02:00
parent b4ee28b11c
commit fe054eba18
No known key found for this signature in database
GPG Key ID: 09E2CD4944E6CBCD
1 changed files with 11 additions and 3 deletions

View File

@ -1,13 +1,13 @@
version = "0.4" version = "0.4"
from flask import Flask, url_for, send_from_directory, render_template, make_response from flask import Flask, url_for, send_from_directory, render_template, make_response, request
from flask_restx import Resource, Api from flask_restx import Resource, Api, reqparse
import os import os
import uuid import uuid
import json
app = Flask(__name__) app = Flask(__name__)
app.url_map.strict_slashes = False app.url_map.strict_slashes = False
api = Api(app, version=version, title='CyCAT.org API', description='CyCAT - The Cybersecurity Resource Catalogue public API services.', doc='/', license='CC-BY', contact='info@cycat.org', ordered=True) api = Api(app, version=version, title='CyCAT.org API', description='CyCAT - The Cybersecurity Resource Catalogue public API services.', doc='/', license='CC-BY', contact='info@cycat.org', ordered=True)
import uuid
import inspect import inspect
import redis import redis
cycat_type = {"1": "Publisher", "2": "Project", "3": "Item"} cycat_type = {"1": "Publisher", "2": "Project", "3": "Item"}
@ -174,5 +174,13 @@ class namespacefinduuid(Resource):
s = r.smembers(k) s = r.smembers(k)
return(list(s)) return(list(s))
@api.route('/propose')
@api.doc(description="Propose new resource to CyCAT.")
class propose(Resource):
def post(self):
x = request.get_json(force=True)
r.rpush("proposal", json.dumps(x))
return {'message': 'Proposal submitted'}, 200
if __name__ == '__main__': if __name__ == '__main__':
app.run() app.run()