Skip to content

Commit e0f1699

Browse files
committed
update learning.py
1 parent d8eca1a commit e0f1699

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

teach/learning.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ def application(environ, start_response):
7777
code = qs['code'][0]
7878
headers = [('Content-Type', 'application/json')]
7979
origin = environ.get('HTTP_ORIGIN', '')
80-
if origin:
81-
headers.append(('Access-Control-Allow-Origin', origin))
80+
if origin.find('www.liaoxuefeng.com') == -1:
81+
start_response('400 Bad Request', [('Content-Type', 'application/json')])
82+
return [b'{"error":"invalid_origin"}']
83+
headers.append(('Access-Control-Allow-Origin', origin))
8284
start_response('200 OK', headers)
8385
r = dict()
8486
try:

0 commit comments

Comments
 (0)