Skip to content

Commit

Permalink
BaseHTTPRequestHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
zkeq authored Jul 16, 2023
1 parent e5c245d commit 18af308
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion api/github/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,27 @@ def error_403(path, user,msg):
return code, data, data_type


print(get_data("zkeq"))
class Handler(BaseHTTPRequestHandler):
def do_GET(self):
path = self.path
try:
user = path.split('?')[1]
except IndexError:
user = None
if user:
_data = get_data(user)
data = json.dumps(_data).encode('utf-8')
code = 200
print("成功获取到Github日历:", user)
data_type = 'application/json'
else:
code, data, data_type = error_403(path, user, "获取Github日历失败:")
if code == 200:
if not _data.get('contributions'):
code, data, data_type = error_403(path, user, "Github日历内容为空:")
self.send_response(code)
self.send_header('Access-Control-Allow-Origin', '*')
self.send_header('Content-type', data_type)
self.end_headers()
self.wfile.write(data)
return

1 comment on commit 18af308

@vercel
Copy link

@vercel vercel bot commented on 18af308 Jul 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

icodeq-api – ./

icodeq-api.vercel.app
api.icodeq.com
icodeq-api-git-main-zkeq.vercel.app
icodeq-api-zkeq.vercel.app

Please sign in to comment.