go_api_topic_list.py 1.2 KB

12345678910111213141516171819202122
  1. from .tool.func import *
  2. def api_topic_list(db_set, name = 'Test', num = 1):
  3. other_set = {}
  4. other_set["name"] = str(name)
  5. other_set["num"] = str(num)
  6. other_set = json.dumps(other_set)
  7. if platform.system() == 'Linux':
  8. if platform.machine() in ["AMD64", "x86_64"]:
  9. 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]
  10. else:
  11. 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]
  12. else:
  13. if platform.machine() in ["AMD64", "x86_64"]:
  14. 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]
  15. else:
  16. 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]
  17. data = data.decode('utf8')
  18. return flask.Response(response = data, status = 200, mimetype = 'application/json')