def today(): if checkcookie(request) == False: return json.dumps({'info': 'please relogin!'}) email = getcookieinfo(request)[0] now = datetime.now() year, month, day = now.year, now.month, now.day querytime = str(year) + str(month) + str(day) allinbox = task.query.filter_by(user=email, buildtime=str(querytime)).all() alltask = {} for k in allinbox: alltask[str(k.id)] = [ k.status, k.user, k.buildtime, k.task, k.project, k.plantime, k.finishtime ] return json.dumps(alltask)
def gtdcli(): if checkcookie(request) == False: return json.dumps({'info': 'please relogin!'}) email = getcookieinfo(request)[0] try: if request.method == 'POST': #print(request.json) body = request.get_json() inboxthing1 = body['inbox'] now = datetime.now() year, month, day = now.year, now.month, now.day buildtime = str(year) + str(month) + str(day) inboxthing = body['inbox'] taskstatus = body['task-status'] plantime = body['plantime'] project = body['project'] print("i am print inbox", inboxthing) try: taskcontent = task(inboxthing, buildtime, user=email, email=email, plantime=plantime, project=project) db.session.add(taskcontent) db.session.commit() db.session.close() return json.dumps({'status': 'u have uploaded successfully'}) except Exception as e: print("erro=======>", e) return json.dumps({'status': 'db error'}) else: return json.dumps({'status': 'upload fail'}) except Exception as e: print('error info', str(e)) return json.dumps({'errorindo': str(e)})
def gtdcli1(): print(request) print( "================>>>>>>>>>>>>>>>>>>>>>>CLIENT<<<<<<<<<<<<<<<<<<===========" ) if checkcookie(request) == False: return json.dumps({'info': 'please relogin!'}) email = getcookieinfo(request)[0] try: if request.method == 'POST': #print(request.json) body = request.get_json() #body = request.json() inboxthing1 = body['inbox'] now = datetime.now() year, month, day = now.year, now.month, now.day buildtime = str(year) + str(month) + str(day) inboxthing = body['inbox'] taskstatus = body['task-status'] plantime = body['plantime'] project = body['project'] print("i am print inbox", inboxthing) try: Session = sessionmaker() engine = create_engine( 'mysql://*****:*****@localhost/dreamteam_db') Session.configure(bind=engine) session = Session() print( "--------------it is buiding session--------------------------------" ) taskcontent = task(inboxthing, buildtime, status=taskstatus, user=email, email=email, plantime=plantime, project=project) session.add(taskcontent) print( "-----------------it is writiing data to database----------------" ) session.commit() session.flush() session.close() print( "-----------------it is closing database--------------------------" ) print( "==================================CLIENT END ==========================" ) return json.dumps({'status': 'u have uploaded successfully'}) except Exception as e: exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] print(exc_type, fname, exc_tb.tb_lineno) print("erro=======>", e) return json.dumps({'status': 'db error'}) else: return json.dumps({'status': 'upload fail'}) except Exception as e: print('error info', str(e)) return json.dumps({'errorindo': str(e)})