Changeset View
Changeset View
Standalone View
Standalone View
swh/scanner/tests/flask_api.py
Show All 13 Lines | def create_app(): | ||||
app = Flask(__name__) | app = Flask(__name__) | ||||
@app.route("/known/", methods=["POST"]) | @app.route("/known/", methods=["POST"]) | ||||
def known(): | def known(): | ||||
swhids = request.get_json() | swhids = request.get_json() | ||||
if len(swhids) > 900: | if len(swhids) > 900: | ||||
raise LargePayloadExc( | raise LargePayloadExc( | ||||
"The maximum number of PIDs this endpoint " "can receive is 900" | "The maximum number of SWHIDs this endpoint can receive is 900" | ||||
) | ) | ||||
res = {swhid: {"known": False} for swhid in swhids} | res = {swhid: {"known": False} for swhid in swhids} | ||||
for swhid in swhids: | for swhid in swhids: | ||||
if swhid in present_swhids: | if swhid in present_swhids: | ||||
res[swhid]["known"] = True | res[swhid]["known"] = True | ||||
return res | return res | ||||
return app | return app |