Surplus_Up (2DU) 7 лет назад
Родитель
Сommit
f90081588d
2 измененных файлов с 11 добавлено и 2 удалено
  1. 6 1
      route/api_version.py
  2. 5 1
      route/tool/func.py

+ 6 - 1
route/api_version.py

@@ -5,7 +5,12 @@ def api_version_2(conn, r_ver, c_ver):
 
 
     new_ver = ''
     new_ver = ''
 
 
-    data = urllib.request.urlopen('https://namu.ml/api/version')
+    try:
+        if flask.request.host != 'namu.ml':
+            data = urllib.request.urlopen('https://namu.ml/api/version')
+    except:
+        pass
+
     if data and data.getcode() == 200:
     if data and data.getcode() == 200:
         try:
         try:
             json_data = json.loads(data.read().decode(data.headers.get_content_charset()))
             json_data = json.loads(data.read().decode(data.headers.get_content_charset()))

+ 5 - 1
route/tool/func.py

@@ -258,7 +258,11 @@ def captcha_post(re_data, num = 1):
             curs.execute('select data from other where name = "sec_re"')
             curs.execute('select data from other where name = "sec_re"')
             sec_re = curs.fetchall()
             sec_re = curs.fetchall()
             if sec_re and sec_re[0][0] != '':
             if sec_re and sec_re[0][0] != '':
-                data = urllib.request.urlopen('https://www.google.com/recaptcha/api/siteverify?secret=' + sec_re[0][0] + '&response=' + re_data)
+                try:
+                    data = urllib.request.urlopen('https://www.google.com/recaptcha/api/siteverify?secret=' + sec_re[0][0] + '&response=' + re_data)
+                except:
+                    pass
+                    
                 if data and data.getcode() == 200:
                 if data and data.getcode() == 200:
                     json_data = json.loads(data.read().decode(data.headers.get_content_charset()))
                     json_data = json.loads(data.read().decode(data.headers.get_content_charset()))
                     if json_data['success'] == True:
                     if json_data['success'] == True: