def find_habit(): response_object = {'status': 'success'} results = [] datetime = '' if request.method == 'POST': data = request.get_json() username = data['username'] year = str(data['year']) if data['month'] > 9: month = str(data['month']) else: month = "0" + str(data['month']) if data['date'] > 9: date = str(data['date']) else: date = "0" + str(data['date']) datetime = year + month + date sql = "select * from habit where username={} and datetime <={}".format( username, int(datetime)) #print(sql) results = statement.find_mysql(sql) response_object['message'] = "Successful request" response_object['resCode'] = 101 response_object['result'] = results else: response_object['message'] = "Unallowed request method." return jsonify(response_object)
def check_habit2(): response_object = {'status': 'success'} datetime = '' inputDetail_results = [] habit_results = [] if request.method == 'GET': username = request.args.get("username") sql = "select date,finished from inputDetail where username={}".format( username) sql2 = "select title,datetime,habit_object,object_number from habit where username={}".format( username) inputDetail_results = statement.find_mysql(sql) habit_results = statement.find_mysql(sql2) response_object['message'] = "Successful request" response_object['resCode'] = 101 response_object['inputDetail_result'] = inputDetail_results response_object['habit_result'] = habit_results else: response_object['message'] = "Unallowed request method." return jsonify(response_object)
def find_all(): print(adminname) if adminname == '' or adminpswd == '': return render_template('adminlogin.html') else: sql1 = "select * from register" rows1 = statement.find_mysql(sql1) sql2 = "select * from habit" rows2 = statement.find_mysql(sql2) sql3 = "select * from inputDetail" rows3 = statement.find_mysql(sql3) sql4 = "select * from admin" rows4 = statement.find_mysql(sql4) sql5 = "select * from addAdvice" rows5 = statement.find_mysql(sql5) return render_template("database.html", rows1=rows1, rows2=rows2, rows3=rows3, rows4=rows4, rows5=rows5)
def check_habit1(): response_object = {'status': 'success'} datetime = '' results = [] if request.method == 'GET': username = request.args.get("username") datetime = request.args.get("datetime") sql = "select title,finished from inputDetail where username={} and date ={}".format( username, datetime) results = statement.find_mysql(sql) response_object['message'] = "Successful request" response_object['resCode'] = 101 response_object['result'] = results else: response_object['message'] = "Unallowed request method." return jsonify(response_object)
def show_habit(): response_object = {'status': 'success'} datetime = '' results = [] if request.method == 'GET': username = request.args.get("username") datetime = request.args.get("datetime") sql = "select * from habit where username={} and datetime <={}".format( username, int(datetime)) results = statement.find_mysql(sql) response_object['message'] = "Successful request" response_object['resCode'] = 101 response_object['result'] = results else: response_object['message'] = "Unallowed request method." return jsonify(response_object)
def check_habit(): response_object = {'status': 'success'} results = [] if request.method == 'POST': data = request.get_json() username = data['username'] datetime = data['datetime'] sql = "select title,finished from inputDetail where username={} and date='{}' ".format( username, datetime) print(sql) results = statement.find_mysql(sql) response_object['message'] = "Successful request" response_object['resCode'] = 101 response_object['result'] = results else: response_object['message'] = "Unallowed request method." return jsonify(response_object)
def update_record4(): n = request.args['id'] sql = "select * from admin where ID = {}".format(n) rows = statement.find_mysql(sql) return render_template("edit4.html", rows=rows)