Surplus_Up (2DU) преди 7 години
родител
ревизия
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 = ''
 
-    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:
         try:
             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"')
             sec_re = curs.fetchall()
             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:
                     json_data = json.loads(data.read().decode(data.headers.get_content_charset()))
                     if json_data['success'] == True: