Spaces:
Runtime error
Runtime error
Create github.py
Browse files
github.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
|
3 |
+
GITHUB_TOKEN = "your_github_token"
|
4 |
+
GITHUB_API_URL = "https://api.github.com"
|
5 |
+
|
6 |
+
def get_repo_code(repo_link):
|
7 |
+
# Extract repository owner and name from link
|
8 |
+
owner, repo = repo_link.split("/")[-2:]
|
9 |
+
repo_url = f"{GITHUB_API_URL}/repos/{owner}/{repo}/contents"
|
10 |
+
|
11 |
+
# Send request to GitHub API
|
12 |
+
headers = {"Authorization": f"Bearer {GITHUB_TOKEN}"}
|
13 |
+
response = requests.get(repo_url, headers=headers)
|
14 |
+
|
15 |
+
# Return repository code files
|
16 |
+
return response.json()
|