diff --git a/leaderboard_github_bot/main.py b/leaderboard_github_bot/main.py index c5ea393..199e839 100644 --- a/leaderboard_github_bot/main.py +++ b/leaderboard_github_bot/main.py @@ -8,6 +8,7 @@ from typing import Union import os from dotenv import load_dotenv +from fastapi.responses import JSONResponse load_dotenv() @@ -15,7 +16,7 @@ origins = [ "http://localhost:5173/leaderboard", - "https://artur-galstyan.github.io/leaderboard/", + "https://kgqa.github.io/leaderboard/", ] app.add_middleware( @@ -57,10 +58,20 @@ class PullRequest(BaseModel): GITHUB_API_URL = "https://api.github.com" -REPO_OWNER = "Artur-Galstyan" +REPO_OWNER = "KGQA" REPO_NAME = "leaderboard" +@app.options("/make_pull_request") +def manual_cors_options(): + headers = { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Methods": "GET, POST, OPTIONS", + "Access-Control-Allow-Headers": "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range", + } + return JSONResponse(content={}, headers=headers) + + @app.post("/make_pull_request") async def make_pull_request(pull_request: PullRequest): issue_body = "" @@ -102,7 +113,7 @@ async def make_pull_request(pull_request: PullRequest): for dataset, dataset_changes in changes.items(): database, datasetname = dataset.split("/") req = httpx.get( - f"https://raw.githubusercontent.com/Artur-Galstyan/leaderboard/main/{database}/{datasetname}.md" + f"https://raw.githubusercontent.com/{REPO_OWNER}/{REPO_NAME}/v2.0/{database}/{datasetname}.md" ) response_text = req.text response_text = response_text.split("---\n")[-1]