2
0

api_w_raw.py 1.0 KB

123456789101112131415161718192021222324252627282930
  1. from .tool.func import *
  2. def api_w_raw(name = 'Test', rev = '', exist_check = ''):
  3. with get_db_connect() as conn:
  4. curs = conn.cursor()
  5. if exist_check != '':
  6. curs.execute(db_change("select title from data where title = ?"), [name])
  7. if data:
  8. return flask.jsonify({ 'exist' : '1' })
  9. else:
  10. return flask.jsonify({})
  11. else:
  12. if rev != '':
  13. curs.execute(db_change("select data from history where title = ? and id = ?"), [name, rev])
  14. else:
  15. curs.execute(db_change("select data from data where title = ?"), [name])
  16. data = curs.fetchall()
  17. if data:
  18. return flask.jsonify({
  19. "title" : name,
  20. "data" : render_set(
  21. doc_name = name,
  22. doc_data = data[0][0],
  23. data_type = 'raw'
  24. )
  25. })
  26. else:
  27. return flask.jsonify({})