def list_tweets_json(): tweet_records = Tweet.query.all() print(tweet_records) tweets = parse_records(tweet_records) return jsonify(tweets)
def list_users(): # assigns the result of querying the user table from the sqlite database that is assigned in the __init__ file "kyle_twitter_db.db" to # the variable db_users db_users = User.query.all() users = parse_records(db_users) return jsonify(users)
def list_books_for_humans(): book_records = Book.query.all() print(book_records) books = parse_records(book_records) return render_template("books.html", message="Here's some books", books=books)
def list_users_json(): user_records = User.query.all() print(user_records) users = parse_records(user_records) return jsonify(users)
def list_tweets(): tweets_records = Tweet.query.all() print(tweets_records) tweets = parse_records(tweets_records) return render_template("tweets.html", message="Here are the Tweets", tweets=tweets)
def list_books_for_humans(): #books = [ # {"id": 1, "title": "Book 1"}, # {"id": 2, "title": "Book 2"}, # {"id": 3, "title": "Book 3"}, #] book_records = Book.query.all() print(book_records) books = parse_records(book_records) # convert to JSON return render_template("books.html", message="Here's some books", books=books) ''' book_records = Book.query.all() print(book_records) # this and book_records.. line above replaces books = .. below as in the query for all books, as in the JSON version of this method above books = [ {"id": 1, "title": "Book 1"}, {"id": 2, "title": "Book 2"}, {"id": 3, "title": "Book 3"}, ] ''' return render_template( "books.html", message="Here's some bookS", books=books ) #render_template fcn looks for the templates folder and HTML file passed to it
def get_strains(): """ Function/endpoint returns all of the entries in the database. """ db_strains = Strains.query.all() response = parse_records(db_strains) return jsonify(response)
def list_users(): user_records = User.query.all() print(user_records) users = parse_records(user_records) return render_template( "users.html", message="Here is a dump of the users stored in the database:", users=users) #@user_routes.route("/users/new") #def new_user(): # return render_template("new_user.html") #@user_routes.route("/users/create", methods=["POST"]) #def create_user(): # print("FORM DATA:", dict(request.form)) # new_user = User(username=request.form["username"]) # db.session.add(new_user) # db.session.commit() # return jsonify({ # "message": "USER CREATED", # "user": dict(request.form) # })
def list_tweets(): tweet_records = Tweet.query.all() print(tweet_records) tweets = parse_records(tweet_records) print(tweets) return render_template( "tweets.html", message="Here is a dump of the tweets stored in the database:", tweets=tweets) #@tweet_routes.route("/tweets/new") #def new_tweet(): # return render_template("new_tweet.html") #@tweet_routes.route("/tweets/create", methods=["POST"]) #def create_tweet(): # print("FORM DATA:", dict(request.form)) # new_tweet = Tweet(tweet_text=request.form["tweet text"]) # db.session.add(new_tweet) # db.session.commit() # return jsonify({ # "message": "TWEET CREATED", # "tweet": dict(request.form) # })
def list_tweets_for_humans(): tweet_records = Tweet.query.all() print(tweet_records) tweets = parse_records(tweet_records) return render_template("tweets.html", message="Here's the list of tweets", tweets=tweets)
def list_users(): #if request.path.endswith(".json"): # return some json #else: # render a template db_users = User.query.all() users = parse_records(db_users) return jsonify(users)
def data(): """View all strains in database.""" DB.drop_all() DB.create_all() create_table(extract_data()) strain = Strain.query.all() records = parse_records(strain) return render_template("data.html", records=records, message="Home Page")
def list_book(): # Similar to a SQLite (app user) query: SELECT * FROM books; asking to rtn all the books exist in DB book_records = Book.query.all( ) # replaces our previous hard-coded books list; list had no functionality jish thinks, so when u go to books/json, we can see smthng..(Not a list we rtn'd anythg from); books=... print(book_records) books = parse_records(book_records) return jsonify(books) # useful for updating a db (jon) to rtn obj '''
def list_books_for_human(): books = [ {"id": 1, "title": "Book 1"}, {"id": 2, "title": "Book 2"}, {"id": 3, "title": "Book 2"}, ] book_records = Book.query.all() books = parse_records(book_records) return render_template("books.html", message="Here's some books", books=books)
def list_users(): ## Can make different results for stacked decorators to reuse functionality #if request.path.endswith(".json"): # return some json #else: # render a template db_users = User.query.all() users = parse_records(db_users) return jsonify(users)
def list_books(): # books = [ # {"id": 1, "title": "Book 1"}, # {"id": 2, "title": "Book 2"}, # {"id": 3, "title": "Book 3"}, # ] book_records = Book.query.all() books_response = parse_records(book_records) return jsonify(books_response)
def index(): db_users = User.query.all() print(db_users) users = parse_records(db_users) print("@@@@@@") print(users) return render_template("prediction_form.html", users=users)
def list_books(): # books = [ # {"id": 1, "title": "Book 1"}, # {"id": 2, "title": "Book 2"}, # {"id": 3, "title": "Book 3"}, # ] book_records = Book.quer.all() print(book_records) books = parse_records(book_records) return jsonify(books)
def list_books(): print("REQUESTED THE BOOKS IN JSON FORMAT") #books = [ # {"id": 1, "title": "Book 1"}, # {"id": 2, "title": "Book 2"}, # {"id": 3, "title": "Book 3"}, #] # todo: get from the database book_records = Book.query.all() books = parse_records(book_records) return jsonify(books)
def list_books(): #books = [ # {"id": 1, "title": "Book 1"}, # {"id": 2, "title": "Book 2"}, # {"id": 3, "title": "Book 3"}, #] user_records = user_records.query.all() print(user_records) users = parse_records(user_records) return jsonify(user)
def list_tweets(): # books = [ # {"id": 1, "title": "Book 1"}, # {"id": 2, "title": "Book 2"}, # {"id": 3, "title": "Book 3"}, # ] tweet_records = Tweetz.query.all() print(tweet_records) tweets = parse_records(tweet_records) return jsonify(tweets)
def list_music(): #music = [ # {"id": 1, "title": "Music 1"}, # {"id": 2, "title": "Music 2"}, # {"id": 3, "title": "Music 3"}, #] music_records = Music.query.all() print(music_records) books = parse_records(music_records) return jsonify(music)
def list_books(): books = [ {"id": 1, "title": "Book 1"}, {"id": 2, "title": "Book 2"}, {"id": 3, "title": "Book 2"}, ] book_records = Book.query.all() books = parse_records(book_records) return jsonify(books)
def list_books_for_humans(): # books = [ # {"id": 1, "title": "Book 1"}, # {"id": 2, "title": "Book 2"}, # {"id": 3, "title": "Book 3"}, # ] book_records = Book.query.all() print(book_records) books = parse_records(book_records) # optionally return render_template("books.html", message="Here's some books", books=books)
def list_tweets(): print("REQUESTED THE TWEETS IN JSON FORMAT") #tweet = [ # {"id": 1, "title": "Book 1"}, # {"id": 2, "title": "Book 2"}, # {"id": 3, "title": "Book 3"}, #] # todo: get from the database tweet_records = Tweet.query.all() tweets = parse_records(tweet_records) return jsonify(tweets)
def list_books(): print('visted books JSON page') #books = [ # {"id": 1, "title": "Book 1"}, # {"id": 2, "title": "Book 2"}, # {"id": 3, "title": "Book 3"}, #] book_records = Book.query.all() books = parse_records(book_records) return jsonify(books)
def list_tweets(): # tweets = [ # {"id": 1, "text": "Tweet 1"}, # {"id": 2, "text": "Tweet 2"}, # {"id": 3, "text": "Tweet 3"}, # ] tweet_records = Tweet.query.all() print(tweet_records) tweets = parse_records(tweet_records) return jsonify(tweets)
def list_books(): # books = [ # {"id": 1, "title": "Book 1"}, # {"id": 2, "title": "Book 2"}, # {"id": 3, "title": "Book 3"}, # ] # SELECT * FROM books book_records = Book.query.all() print(book_records) books = parse_records(book_records) # parse_records to convert the book_records into dictionaries return jsonify(books)
def list_books_for_humans(): # books = [ # {"id": 1, "title": "Book 1"}, # {"id": 2, "title": "Book 2"}, # {"id": 3, "title": "Book 3"}, # ] # SELECT * FROM books book_records = Book.query.all() print(book_records) books = parse_records(book_records) # parse_records to convert the book_records into dictionaries return render_template("books.html", message="Here's some books", books=books)
def list_books(): books = [ {"id": 1, "title": "Book 1"}, {"id": 2, "title": "Book 2"}, {"id": 3, "title": "Book 3"}, ] # SELECT * FROM books book_records = Book.query.all() print(book_records) books = parse_records(book_records) return jsonify(books)