chat / github.py
prometheus04's picture
Update github.py
d1f9e51 verified
raw
history blame contribute delete
516 Bytes
import requests
GITHUB_TOKEN = "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"
GITHUB_API_URL = "https://api.github.com"
def get_repo_code(repo_link):
# Extract repository owner and name from link
owner, repo = repo_link.split("/")[-2:]
repo_url = f"{GITHUB_API_URL}/repos/{owner}/{repo}/contents"
# Send request to GitHub API
headers = {"Authorization": f"Bearer {GITHUB_TOKEN}"}
response = requests.get(repo_url, headers=headers)
# Return repository code files
return response.json()