def update(): print(checkcookie_time(request)) if checkcookie(request) == False: return json.dumps({'info': 'please relogin!'}) try: if request.method == 'POST': body = request.get_json() taskstatus = body['taskstatus'] idcli = body['id'] project = body['project'] print("project is ---", project) plantime = body['plantime'] if taskstatus == "finish": now = datetime.now() year, month, day = now.year, now.month, now.day finishtime = str(year) + str(month) + str(day) #database update instaruct target_task = task.query.filter_by(id=idcli).first() #if the updated id doesnot exsit.it will lead bug target_task.project = project print('i have there') target_task.plantime = plantime target_task.finishtime = finishtime target_task.status = taskstatus db.session.commit() db.session.close() return json.dumps({'status': 'u have uploaded successfully'}) except Exception as e: print(e) return json.dumps({'status': 'u have uploaded fail'})
def inbox(): #i want to write it to a fcuntion!!!! #get cookie key and value useremail = request.cookies.get('email') dbuser = User.query.filter_by(email=useremail).first() #db.session.commit() #db.session.close() print(dbuser.cookie) if checkcookie_time(request) > 360000: return redirect('/') #https://teamtreehouse.com/community/flask-redirect-vs-redirecturlfor if dbuser.cookie != useremail: return redirect('/') allinbox = task.query.filter_by(project='inbox').order_by(task.id).all() for k in allinbox: print(k.task) #db.session.commit() db.session.close() return render_template("inbox.html", my_list=allinbox)
def inbox(): print( "===================================WEB F**K ME=======================" ) useremail = request.cookies.get('email') Session = sessionmaker() engine = create_engine('mysql://*****:*****@localhost/dreamteam_db') Session.configure(bind=engine) session = Session() dbuser = session.query(User).filter_by(email=useremail).first() session.flush() #i want to write it to a fcuntion!!!! #get cookie key and value #dbuser = User.query.filter_by(email=useremail).first() #db.session.commit() #db.session.close() #print(dbuser.cookie) if checkcookie_time(request) > 360000: return redirect('/') #https://teamtreehouse.com/community/flask-redirect-vs-redirecturlfor if dbuser.cookie != useremail: return redirect('/') #many filter example allinbox = session.query(task).filter_by( project='inbox', email=useremail).order_by(task.id).all() print("+++++++++++++++++++i am debuging++++++++++++++++++++++++") #print(allinbox) print("------------------above inbox----------------------------------") #allinbox = task.query.filter_by(project='inbox').order_by(task.id).all() #for k in allinbox: #print(k.task) #db.session.commit() #db.session.close() session.flush() session.close() print( "666666666666666666666666------WEB END-------------8888888888888888888" ) return render_template("inbox.html", my_list=allinbox)