2
0

api_raw.py 872 B

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