def get_entries(): """Returns all the entries from a user, filtered by namefilter.""" if not 'username' in session or \ not 'password' in session or \ not database.login_user(session['username'], session['password']): return jsonify(ok=0, msg='User is not log in') namefilter = request.args.get('nameFilter', None) entries = database.get_entries(session['userid'], namefilter) data = "[" addcomma = False for entrie in entries: if addcomma: data += ", " else: addcomma = True data += '{"name": "' + entrie['name'] + '", "cityName": "' + \ entrie['cityName'] + '", "gmt": ' + str(entrie['gmt']) + \ ', "id": '+ str(entrie['id']) +'}' data += "]" return jsonify(ok=1, entries=data)
2) View entries. 3) Exit. Your selection: """ welcome = "Welcome to the programming diary!" def prompt_new_entry(): entry_content = input("What have you learned today?\n") entry_date = input("Enter the date: ") add_entry(entry_content, entry_date) def view_entries(entries): for entry in entries: # each row in the result is a tuple, # not a dictionary. print(f"{entry['date']}:\n{entry['content']}\n\n") print(welcome) create_table() # ':=' is the walrus operator. # python >= 3.8 is require for its use. while (user_input := input(menu)) != "3": if user_input == "1": prompt_new_entry() elif user_input == "2": view_entries(get_entries()) else: print("Invalid option, please try again!")
def evt_songs(): return render_template("impressions.html", entries=database.get_entries())
# user input questions entry_content = input("What have you learned today? ") entry_date = input("Enter the date: ") # Using add_entry function in database.py add_entry(entry_content, entry_date) # Funtion for getting all entries def prompt_view_entry(entries): # Printing out all entries currently in the programming journal for entry in entries: print(f"{entry['date']}\n{entry['content']}\n\n") # User input for menu option user_input = input(menu) # Menu option conditions while user_input != "3": if user_input == "1": prompt_new_entry() elif user_input == "2": # Using get_entries function in database.py prompt_view_entry(get_entries()) else: print("Invalid option, please try again") user_input = input(menu)
# Store inputs to database add_entry(input_date, input_contents) def view_entries(entries): for entry in entries: # entry = row of 'entries 'table --> tuple print('\n{}\n{}'.format(entry[1], entry[2])) # RUN app print(welcome_message) user_input = input(initial_message) while user_input != '3': if user_input == '1': prompt_inputs() elif user_input == '2': entries = get_entries() view_entries(entries) else: print('\nInvalid option. Please try again.\n') user_input = input(initial_message) # Using 'assignment expression' (> Python 3.8) # while (user_input := input(initial_message)) != '3' :
def evt_songs(): if can_see_submissions(): return render_template("impressions.html", entries=database.get_entries()) else: return render_template("section_closed.html")
def entries(form_id): ''' Function to GET entries created using particular form ''' labels = request.args.get('labels') return database.get_entries(form_id, labels)