2
0

api_version.py 571 B

12345678910111213141516171819
  1. from .tool.func import *
  2. def api_version_2(conn, r_ver, c_ver):
  3. curs = conn.cursor()
  4. new_ver = ''
  5. data = urllib.request.urlopen('https://namu.ml/api/version')
  6. if data and data.getcode() == 200:
  7. try:
  8. json_data = json.loads(data.read().decode(data.headers.get_content_charset()))
  9. if 'version' in json_data:
  10. new_ver = json_data['version']
  11. except:
  12. pass
  13. json_data = { "version" : r_ver, "db_version" : c_ver, "lastest_version" : new_ver }
  14. return flask.jsonify(json_data)