G2A Many GEOs
SHARE
TWEET

Untitled

a guest Mar 29th, 2020 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @mod.route('/data' ,methods = ['GET'] )
  2. def data():
  3.  
  4.     offset = int(request.args['offset'])
  5.     limit = int(request.args['limit'])
  6.    
  7.     s = coll_gazora.count() #Elemek számolása
  8.  
  9.     button_list = list(range(s//5+2)) # gombok száma
  10.    
  11.     #gombok és url összeállítása
  12.     d = []
  13.     for u in button_list:
  14.         d.append({'u':u+1, 'url':'?limit=5&offset='+str(int(u)*5)})
  15.  
  16.  
  17.     #rendezés
  18.     start_id = coll_gazora.find().sort('_id',pymongo.ASCENDING)
  19.    
  20.     last_id = start_id[offset]['_id']
  21.    
  22.     res = coll_gazora.find({'_id': {'$gte': last_id}}).sort('_id',pymongo.ASCENDING).limit(limit)
  23.  
  24.     output = []
  25.     for i in res:
  26.         output.append ({'_id':i['_id'],'date':i['date'],'clock_position':i['clock_position'],'consumption':i['consumption']})
  27.  
  28.     # Hibakezelés
  29.  
  30.     if (offset+limit) < s:
  31.         next_url = '?limit=' + str(limit) + '&offset='+ str(offset+limit)
  32.     else: next_url = ""
  33.    
  34.     if (offset-limit) >= 0:
  35.         prev_url = '?limit=' + str(limit) + '&offset='+ str(offset-limit)
  36.     else: prev_url = ""
  37.    
  38.     return render_template('gasmeter/data.html ', d = d[:-1] ,output = output, next_url = next_url, prev_url = prev_url )
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top