2
0

api_topic_sub.py 711 B

123456789101112131415161718192021
  1. from .tool.func import *
  2. def api_topic_sub_2(conn, name, sub, time):
  3. curs = conn.cursor()
  4. if flask.request.args.get('time', None):
  5. curs.execute("select id, data, ip from topic where title = ? and sub = ? and date >= ? order by id + 0 asc", [name, sub, flask.request.args.get('time', None)])
  6. else:
  7. curs.execute("select id, data, ip from topic where title = ? and sub = ? order by id + 0 asc", [name, sub])
  8. data = curs.fetchall()
  9. if data:
  10. json_data = {}
  11. for i in data:
  12. json_data[i[0]] = {
  13. "data" : i[1],
  14. "id" : i[2]
  15. }
  16. return flask.jsonify(json_data)
  17. else:
  18. return flask.jsonify({})