api_image_view.py 753 B

12345678910111213141516171819202122
  1. from .tool.func import *
  2. def api_image_view(name = 'Test'):
  3. with get_db_connect() as conn:
  4. if flask.request.method == 'POST':
  5. try:
  6. title_list = json.loads(flask.request.form.get('title_list', ''))
  7. title_list = list(set(title_list))
  8. except:
  9. title_list = []
  10. data_list = {}
  11. for i in title_list:
  12. if os.path.exists(os.path.join(load_image_url(), i)):
  13. data_list[i] = '1'
  14. return flask.jsonify(data_list)
  15. else:
  16. if os.path.exists(os.path.join(load_image_url(), name)):
  17. return flask.jsonify({ "exist" : "1" })
  18. else:
  19. return flask.jsonify({})