Spaces:
Sleeping
Sleeping
Saketh-Reddy
commited on
Commit
•
55af089
1
Parent(s):
66a0ed8
Update main.py
Browse files
main.py
CHANGED
@@ -16,26 +16,16 @@ def read_root():
|
|
16 |
return {"Hello": "World!"}
|
17 |
|
18 |
@app.post("/webhook")
|
19 |
-
async def
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
and payload.event.scope.startswith("repo.content")
|
32 |
-
and payload.repo.name == "SakethTest/ThirdParty"
|
33 |
-
and payload.repo.type == "model"
|
34 |
-
):
|
35 |
-
# no-op
|
36 |
-
return {"processed": False}
|
37 |
|
38 |
-
snapshot_download(repo_id="SakethTest/ThirdParty",local_dir="./ThirdParty")
|
39 |
-
api.upload_folder(folder_path="./ThirdParty",repo_id="shellplc/ThirdParty",repo_type="model",commit_message="uploaded third party model",token="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")
|
40 |
-
|
41 |
-
return {"processed": True}
|
|
|
16 |
return {"Hello": "World!"}
|
17 |
|
18 |
@app.post("/webhook")
|
19 |
+
async def webhook(request: Request):
|
20 |
+
if request.method == "POST":
|
21 |
+
if request.headers.get("X-Webhook-Secret") != "webhooksecret":
|
22 |
+
return Response("Invalid secret", status_code=401)
|
23 |
+
data = await request.json()
|
24 |
+
result = create_or_update_report(data)
|
25 |
+
if(data["event"]["action"]=="update" and data["event"]["scope"]=="repo.content" and data["repo"]["type"]=="model"):
|
26 |
+
snapshot_download(repo_id="SakethTest/ThirdParty",local_dir="./ThirdParty")
|
27 |
+
api.upload_folder(folder_path="./ThirdParty",repo_id="shellplc/ThirdParty",repo_type="model",commit_message="uploaded third party model",token="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")
|
28 |
+
return {"processed": True}
|
29 |
+
else:
|
30 |
+
return {"processed": False}
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
|
|
|
|
|
|
|