chat / github.py
prometheus04's picture
Create github.py
7e069fc verified
raw
history blame
493 Bytes
import requests
GITHUB_TOKEN = "your_github_token"
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()