so i am trying to allow the user to only retrieve 50 queries at a time from the database using a flask server. Here is my logic
server.py
@app.route('/getEmployees/<userid>')
def all(userid):
# Allow the user to specify an offset via querystring
offset = request.args.get('offset')
# Allow user to specify limit but default to 50
limit = request.args.get('limit', 50)
if offset is None:
# Look in the session and default to 0 if not defined
offset = session.get('offset', 0)
g.db = connect_db()
cur = g.db.execute('select * from employees limit %d offset %d' % (limit, int(offset)))
entry=[dict(emp_no=row[0],birth_date=row[1],first_name=row[2],last_name=row[3],gender=row[4],hire_date=row[5]) for row in cur.fetchall()]
g.db.close()
session['offset']= offset + limit;
return str(entry)
now gooduser.py
from timeit import default_timer
import urllib2
userid='gooduser'
start=default_timer()
req = urllib2.Request('http://0.0.0.0:5000/getEmployees/'+str(userid))
response = urllib2.urlopen(req)
the_page = response.read()
duration = default_timer() - start
print the_page
print duration
running python gooduser.py in terminal multiple times gives me the fisrt 50 tuples everytime. But when i go to http://0.0.0.0:5000/getEmployees/gooduser on my browser gives me the next 50 entries whenever i refresh it. How do i get gooduser.py working on the terminal too and get the next 50 entries.