2
0

go_api_func_language.py 1.5 KB

123456789101112131415161718192021222324252627
  1. from .tool.func import *
  2. def api_func_language(db_set, data = 'Test'):
  3. with get_db_connect() as conn:
  4. other_set = {}
  5. if flask.request.method == 'POST':
  6. other_set["data"] = flask.request.form.get('data', '')
  7. other_set["data"] = other_set["data"].split(' ')
  8. else:
  9. other_set["data"] = [data]
  10. other_set = json.dumps(other_set)
  11. if platform.system() == 'Linux':
  12. if platform.machine() in ["AMD64", "x86_64"]:
  13. 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]
  14. else:
  15. 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]
  16. else:
  17. if platform.machine() in ["AMD64", "x86_64"]:
  18. 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]
  19. else:
  20. 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]
  21. data = data.decode('utf8')
  22. return flask.Response(response = data, status = 200, mimetype = 'application/json')