def select_time(): if request.method == 'POST': # A POST request # # You can fetch the parameters passed to the URL # by calling `request.form' for POST requests post_params = request.form MM = post_params['MM'] dd = post_params['dd'] yyyy = post_params['yyyy'] HH = post_params['HH'] mm = post_params['mm'] ss = post_params['ss'] enter_name = post_params['entername'] selected_time = '%s-%s-%s %s:%s:%s' % (yyyy, MM, dd, HH, mm, ss) update_message = '(Hello, %s. Previously selected time was: %s.)' % (enter_name, selected_time) # TODO: save the selected time as the current time in the database sqlitedb.setTime(selected_time) # Here, we assign `update_message' to `message', which means # we'll refer to it in our template as `message' return render_template('select_time.html', message = update_message) else: return render_template('select_time.html')
def POST(self): post_params = web.input() MM = post_params['MM'] dd = post_params['dd'] yyyy = post_params['yyyy'] HH = post_params['HH'] mm = post_params['mm'] ss = post_params['ss'] enter_name = post_params['entername'] selected_time = '%s-%s-%s %s:%s:%s' % (yyyy, MM, dd, HH, mm, ss) update_message = '(Hello, %s. Previously selected time was: %s.)' % ( enter_name, selected_time) # TODO: save the selected time as the current time in the database t = sqlitedb.transaction() try: sqlitedb.setTime(selected_time) except Exception as e: t.rollback() print str(e) update_message = str(e) else: t.commit() # Here, we assign `update_message' to `message', which means # we'll refer to it in our template as `message' return render_template('select_time.html', message=update_message)
def POST(self): post_params = web.input() MM = post_params['MM'] dd = post_params['dd'] yyyy = post_params['yyyy'] HH = post_params['HH'] mm = post_params['mm'] ss = post_params['ss'] enter_name = post_params['entername'] selected_time = '%s-%s-%s %s:%s:%s' % (yyyy, MM, dd, HH, mm, ss) # TODO: save the selected time as the current time in the database result = sqlitedb.setTime(selected_time) if (result): update_message = '(Hello, %s. The Current Time is set to : %s.)' % ( enter_name, selected_time) else: update_message = 'Hello %s, the entered time - %s is not valid!' % ( enter_name, selected_time) # Here, we assign `update_message' to `message', which means # we'll refer to it in our template as `message' return render_template('select_time.html', content={ "status": result, "message": update_message })
def POST(self): post_params = web.input() MM = post_params['MM'] dd = post_params['dd'] yyyy = post_params['yyyy'] HH = post_params['HH'] mm = post_params['mm'] ss = post_params['ss'] enter_name = post_params['entername'] selected_time = '%s-%s-%s %s:%s:%s' % (yyyy, MM, dd, HH, mm, ss) update_message = '(Hello, %s. Previously selected time was: %s.)' % ( enter_name, selected_time) sqlitedb.setTime(string_to_time(selected_time)) # Here, we assign `update_message' to `message', which means # we'll refer to it in our template as `message' return render_template('select_time.html', message=update_message)
def POST(self): post_params = web.input() MM = post_params['MM'] dd = post_params['dd'] yyyy = post_params['yyyy'] HH = post_params['HH'] mm = post_params['mm'] ss = post_params['ss']; enter_name = post_params['entername'] selected_time = '%s-%s-%s %s:%s:%s' % (yyyy, MM, dd, HH, mm, ss) update_message = '(Hello, %s. Previously selected time was: %s.)' % (enter_name, selected_time) # save the selected time as the current time in the database sqlitedb.setTime(selected_time) # Here, we assign `update_message' to `message', which means # we'll refer to it in our template as `message' return render_template('select_time.html', message = update_message)
def POST(self): post_params = web.input() MM = post_params['MM'] dd = post_params['dd'] yyyy = post_params['yyyy'] HH = post_params['HH'] mm = post_params['mm'] ss = post_params['ss'] enter_name = post_params['entername'] selected_time = '%s-%s-%s %s:%s:%s' % (yyyy, MM, dd, HH, mm, ss) update_message = '(Hello, %s. Previously selected time was: %s.)' % ( enter_name, selected_time) # TODO: save the selected time as the current time in the database try: sqlitedb.setTime(selected_time) except: update_message = '(Hello, %s. Unfortunately, time cannot move backward)' % ( enter_name) return render_template('select_time.html', message=update_message) # Here, we assign `update_message' to `message', which means # we'll refer to it in our template as `message' return render_template('select_time.html', message=update_message)
def POST(self): post_params = web.input() MM = post_params['MM'] dd = post_params['dd'] yyyy = post_params['yyyy'] HH = post_params['HH'] mm = post_params['mm'] ss = post_params['ss']; enter_name = post_params['entername'] selected_time = '%s-%s-%s %s:%s:%s' % (yyyy, MM, dd, HH, mm, ss) update_message = '(Hello, %s. Previously selected time was: %s.)' % (enter_name, selected_time) # TODO: save the selected time as the current time in the database if sqlitedb.setTime(selected_time) == False : return render_template('select_time.html', message = 'Error: failed to set time') # Here, we assign `update_message' to `message', which means # we'll refer to it in our template as `message' return render_template('select_time.html', message = update_message)
def POST(self): post_params = web.input() MM = post_params['MM'] dd = post_params['dd'] yyyy = post_params['yyyy'] HH = post_params['HH'] mm = post_params['mm'] ss = post_params['ss']; enter_name = post_params['entername'] selected_time = '%s-%s-%s %s:%s:%s' % (yyyy, MM, dd, HH, mm, ss) update_message = '(Hello, %s. Previously selected time was: %s.)' % (enter_name, selected_time) # function setTime will return "error" or "success" to represent the status of the database operation result = sqlitedb.setTime(selected_time) if result != "success": return render_template('select_time.html', message="ERROR! " + result) # print result return render_template('select_time.html', message=update_message)
def POST(self): post_params = web.input() MM = post_params['MM'] dd = post_params['dd'] yyyy = post_params['yyyy'] HH = post_params['HH'] mm = post_params['mm'] ss = post_params['ss'] enter_name = post_params['entername'] selected_time = '%s-%s-%s %s:%s:%s' % (yyyy, MM, dd, HH, mm, ss) update_message = '(Hello, %s. Previously selected time was: %s.)' % ( enter_name, selected_time) # TODO: save the selected time as the current time in the database result = sqlitedb.setTime(selected_time) if result: return render_template('select_time.html', message=update_message) return render_template('select_time.html', message='Enter a Valid Time')
def POST(self): post_params = web.input() MM = post_params['MM'] dd = post_params['dd'] yyyy = post_params['yyyy'] HH = post_params['HH'] mm = post_params['mm'] ss = post_params['ss'] enter_name = post_params['entername'] selected_time = '%s-%s-%s %s:%s:%s' % (yyyy, MM, dd, HH, mm, ss) update_message = 'Welcome to the future, %s! Time has progressed to: %s.' % ( enter_name, selected_time) err_message = "A problem occurred, the time was not updated. Remember, time can only go forwards!" #save the selected time as the current time in the database if (sqlitedb.setTime(selected_time)): # Here, we assign `update_message' to `message', which means # we'll refer to it in our template as `message' return render_template('select_time.html', message=update_message) else: return render_template('select_time.html', message=err_message)