Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9312453
flask_api.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
875 B
Subscribers
None
flask_api.py
View Options
# Copyright (C) 2020 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
from
flask
import
Flask
,
request
from
swh.web.common.exc
import
LargePayloadExc
from
.data
import
present_swhids
def
create_app
():
app
=
Flask
(
__name__
)
@app.route
(
"/known/"
,
methods
=
[
"POST"
])
def
known
():
swhids
=
request
.
get_json
()
if
len
(
swhids
)
>
900
:
raise
LargePayloadExc
(
"The maximum number of SWHIDs this endpoint can receive is 900"
)
res
=
{
swhid
:
{
"known"
:
False
}
for
swhid
in
swhids
}
for
swhid
in
swhids
:
if
swhid
in
present_swhids
:
res
[
swhid
][
"known"
]
=
True
return
res
return
app
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Thu, Jul 3, 10:53 AM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3451853
Attached To
rDTSCN Code scanner
Event Timeline
Log In to Comment