From ad1e3448fae926a952a9ecf0acdd0509ecda6147 Mon Sep 17 00:00:00 2001 From: Zhicheng Zhang <20331014+zzc-tongji@users.noreply.github.com> Date: Mon, 15 Jul 2024 04:49:22 +0000 Subject: [PATCH] support site api.github.com --- app/main.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index 8747290..0be646b 100644 --- a/app/main.py +++ b/app/main.py @@ -48,6 +48,7 @@ exp2 = re.compile(r'^(?:https?://)?github\.com/(?P.+?)/(?P.+?)/(?: exp3 = re.compile(r'^(?:https?://)?github\.com/(?P.+?)/(?P.+?)/(?:info|git-).*$') exp4 = re.compile(r'^(?:https?://)?raw\.(?:githubusercontent|github)\.com/(?P.+?)/(?P.+?)/.+?/.+$') exp5 = re.compile(r'^(?:https?://)?gist\.(?:githubusercontent|github)\.com/(?P.+?)/.+?/.+$') +exp6 = re.compile(r'^(?:https?://)?api\.github\.com/.*$') requests.sessions.default_headers = lambda: CaseInsensitiveDict() @@ -107,14 +108,14 @@ def iter_content(self, chunk_size=1, decode_unicode=False): def check_url(u): - for exp in (exp1, exp2, exp3, exp4, exp5): + for exp in (exp1, exp2, exp3, exp4, exp5, exp6): m = exp.match(u) if m: return m return False -@app.route('/', methods=['GET', 'POST']) +@app.route('/', methods=['GET', 'POST', 'PATCH', 'DELETE']) def handler(u): u = u if u.startswith('http') else 'https://' + u if u.rfind('://', 3, 9) == -1: