go_api_user_setting_editor.py 1.6 KB

12345678910111213141516171819202122232425262728293031
  1. from .tool.func import *
  2. def api_user_setting_editor(db_set):
  3. with get_db_connect() as conn:
  4. other_set = {}
  5. other_set["ip"] = ip_check()
  6. func_name = sys._getframe().f_code.co_name
  7. if flask.request.method == 'POST':
  8. func_name += '_insert'
  9. other_set['data'] = flask.request.form.get('data', 'Test')
  10. elif flask.request.method == 'DELETE':
  11. func_name += '_delete'
  12. other_set['data'] = flask.request.form.get('data', 'Test')
  13. other_set = json.dumps(other_set)
  14. if platform.system() == 'Linux':
  15. if platform.machine() in ["AMD64", "x86_64"]:
  16. data = subprocess.Popen([os.path.join(".", "route_go", "bin", "main.amd64.bin"), sys._getframe().f_code.co_name, db_set, other_set], stdout = subprocess.PIPE).communicate()[0]
  17. else:
  18. data = subprocess.Popen([os.path.join(".", "route_go", "bin", "main.arm64.bin"), sys._getframe().f_code.co_name, db_set, other_set], stdout = subprocess.PIPE).communicate()[0]
  19. else:
  20. if platform.machine() in ["AMD64", "x86_64"]:
  21. data = subprocess.Popen([os.path.join(".", "route_go", "bin", "main.amd64.exe"), sys._getframe().f_code.co_name, db_set, other_set], stdout = subprocess.PIPE).communicate()[0]
  22. else:
  23. data = subprocess.Popen([os.path.join(".", "route_go", "bin", "main.arm64.exe"), sys._getframe().f_code.co_name, db_set, other_set], stdout = subprocess.PIPE).communicate()[0]
  24. data = data.decode('utf8')
  25. return flask.Response(response = data, status = 200, mimetype = 'application/json')