Spaces:
Running
Running
1to
Browse files
app.py
CHANGED
|
@@ -24,8 +24,9 @@ async def fetch_github_trending():
|
|
| 24 |
}
|
| 25 |
|
| 26 |
headers = {}
|
| 27 |
-
|
| 28 |
-
|
|
|
|
| 29 |
|
| 30 |
try:
|
| 31 |
response = requests.get(url, params=params, headers=headers)
|
|
@@ -55,7 +56,7 @@ async def trending_generator():
|
|
| 55 |
while True:
|
| 56 |
# 每5分钟更新一次数据
|
| 57 |
if not last_updated or (datetime.now() - last_updated) > timedelta(minutes=5):
|
| 58 |
-
await fetch_github_trending()
|
| 59 |
|
| 60 |
# 发送当前数据
|
| 61 |
yield f"data: {cached_trending}\n\n"
|
|
|
|
| 24 |
}
|
| 25 |
|
| 26 |
headers = {}
|
| 27 |
+
github_token = os.getenv("GITHUB_TOKEN")
|
| 28 |
+
if github_token:
|
| 29 |
+
headers["Authorization"] = f"token {github_token}" # 修复f-string引号问题
|
| 30 |
|
| 31 |
try:
|
| 32 |
response = requests.get(url, params=params, headers=headers)
|
|
|
|
| 56 |
while True:
|
| 57 |
# 每5分钟更新一次数据
|
| 58 |
if not last_updated or (datetime.now() - last_updated) > timedelta(minutes=5):
|
| 59 |
+
await fetch_github_trending() # 修复拼写错误(原trending->trending)
|
| 60 |
|
| 61 |
# 发送当前数据
|
| 62 |
yield f"data: {cached_trending}\n\n"
|