Example #1
0
def rand_question_count(count):
  uid = request.cookies.get(cookie_name)
  uid = db.refresh_user_id(r, uid)

  q = db.random_question(r, uid, count)
  resp = make_response(json.dumps(q))
  resp.set_cookie(cookie_name, uid)
  return resp
Example #2
0
def rand_question():
  uid = request.cookies.get(cookie_name)
  uid = db.refresh_user_id(r, uid)

  q = db.random_question(r, uid)
  if len(q) < 1:
    resp = make_response(('', 404, []))
    return resp

  resp = make_response(json.dumps(q[0]))
  resp.set_cookie(cookie_name, uid)
  return resp