Exemple #1
0
def getResponse(request):

    body = request.get_json(force = True, silent = True)
    #date = body['date']
    time = datetime.now()
    records_list = []
    for record in body['records']:
	
	for i in range(0, int(record['groups'])):

	    catalog = record['catalog']
	    catalog_id = catalog2uid(catalog)
            exercise = record['exercise']
	    exercise_id = exercise2uid(exercise, catalog)
	    resistance = record['resistance']
	    repetition = record['repetition']
	    date = record['date']
            tagid = record['tagid']
	    uid = str(uuid1())
	
	    data = (uid,exercise_id,catalog_id,resistance,repetition,date,time)
	    connection = sqlite3.connect('test.db')
	    cur = connection.cursor()
	    cur.execute('INSERT INTO main VALUES(?,?,?,?,?,?,?)',data)
    	    connection.commit()
    	    connection.close()
            record_dict = {
                           'exercise': exercise,
                           'catalog': catalog,
                           'resistance': resistance,
                           'repetition': repetition,
                           'date': date,
                           'uuid': uid,
			   'tagid': tagid
                           }
            records_list.append(record_dict)
    result_dict = { 'records': records_list}
    return jsonify(result_dict)