Skip to content

Commit 42e9365

Browse files
committed
调整
1 parent c0d020b commit 42e9365

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

api/index.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,34 @@
55
import json
66

77
def list_split(items, n):
8-
return [items[i:i+n] for i in range(0, len(items), n)]
9-
10-
8+
return [items[i:i + n] for i in range(0, len(items), n)]
119
def getdata(name):
12-
gitpage = requests.get("https://github.com/" +name)
10+
gitpage = requests.get("https://github.com/" + name)
1311
data = gitpage.text
1412
datadatereg = re.compile(r'data-date="(.*?)"/>')
1513
datacountreg = re.compile(r'data-count="(.*?)" data-date')
1614
datadate = datadatereg.findall(data)
1715
datacount = datacountreg.findall(data)
18-
datacount =list(map(int, datacount))
16+
datacount = list(map(int, datacount))
1917
contributions = sum(datacount)
20-
datalist=[]
21-
for index,item in enumerate(datadate):
22-
itemlist = {"date":item,"count":datacount[index]}
18+
datalist = []
19+
for index, item in enumerate(datadate):
20+
itemlist = {"date": item, "count": datacount[index]}
2321
datalist.append(itemlist)
2422
datalistsplit = list_split(datalist, 7)
2523
returndata = {
26-
"total":contributions,
27-
"contributions":datalistsplit
24+
"total": contributions,
25+
"contributions": datalistsplit
2826
}
29-
3027
return returndata
31-
3228
class handler(BaseHTTPRequestHandler):
33-
3429
def do_GET(self):
3530
path = self.path
3631
user = path.split('?')[1]
3732
data = getdata(user)
3833
self.send_response(200)
3934
self.send_header('Access-Control-Allow-Origin', '*')
40-
self.send_header('Content-type','application/json')
35+
self.send_header('Content-type', 'application/json')
4136
self.end_headers()
4237
self.wfile.write(json.dumps(data).encode('utf-8'))
4338
return

0 commit comments

Comments
 (0)