generated from prof-rossetti/flask-sheets-template-2023
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
90 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,34 @@ | ||
|
||
#from app.db import BaseModel | ||
# | ||
#class Book(BaseModel): | ||
# | ||
# SHEET_NAME = "books" | ||
# | ||
# COLUMNS = ["title", "author", "year"] | ||
# | ||
# SEEDS = [ | ||
# {"title": "To Kill a Mockingbird", "author": "Harper Lee", "year": 1960}, | ||
# {"title": "1984", "author": "George Orwell", "year": 1949}, | ||
# {"title": "The Great Gatsby", "author": "F. Scott Fitzgerald", "year": 1925}, | ||
# {"title": "The Catcher in the Rye", "author": "J.D. Salinger", "year": 1951}, | ||
# {"title": "Pride and Prejudice", "author": "Jane Austen", "year": 1813}, | ||
# {"title": "To the Lighthouse", "author": "Virginia Woolf", "year": 1927}, | ||
# {"title": "The Hobbit", "author": "J.R.R. Tolkien", "year": 1937}, | ||
# {"title": "Moby-Dick", "author": "Herman Melville", "year": 1851}, | ||
# {"title": "Brave New World", "author": "Aldous Huxley", "year": 1932}, | ||
# {"title": "Alice's Adventures in Wonderland", "author": "Lewis Carroll", "year": 1865}, | ||
# {"title": "Harry Potter and the Philosopher's Stone", "author": "J.K. Rowling", "year": 1997}, | ||
# {"title": "Harry Potter and the Chamber of Secrets", "author": "J.K. Rowling", "year": 1998}, | ||
# ] | ||
# | ||
# | ||
#if __name__ == "__main__": | ||
# | ||
# books = Book.all() | ||
# print("FOUND", len(books), "BOOKS") | ||
# if any(books): | ||
# for book in books: | ||
# print(book.title, book.author, book.year) | ||
# else: | ||
# Book.seed() | ||
# | ||
from app.db import BaseModel | ||
|
||
class Book(BaseModel): | ||
|
||
SHEET_NAME = "books" | ||
|
||
COLUMNS = ["title", "author", "year"] | ||
|
||
SEEDS = [ | ||
{"title": "To Kill a Mockingbird", "author": "Harper Lee", "year": 1960}, | ||
{"title": "1984", "author": "George Orwell", "year": 1949}, | ||
{"title": "The Great Gatsby", "author": "F. Scott Fitzgerald", "year": 1925}, | ||
{"title": "The Catcher in the Rye", "author": "J.D. Salinger", "year": 1951}, | ||
{"title": "Pride and Prejudice", "author": "Jane Austen", "year": 1813}, | ||
{"title": "To the Lighthouse", "author": "Virginia Woolf", "year": 1927}, | ||
{"title": "The Hobbit", "author": "J.R.R. Tolkien", "year": 1937}, | ||
{"title": "Moby-Dick", "author": "Herman Melville", "year": 1851}, | ||
{"title": "Brave New World", "author": "Aldous Huxley", "year": 1932}, | ||
{"title": "Alice's Adventures in Wonderland", "author": "Lewis Carroll", "year": 1865}, | ||
{"title": "Harry Potter and the Philosopher's Stone", "author": "J.K. Rowling", "year": 1997}, | ||
{"title": "Harry Potter and the Chamber of Secrets", "author": "J.K. Rowling", "year": 1998}, | ||
] | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
books = Book.all() | ||
print("FOUND", len(books), "BOOKS") | ||
if any(books): | ||
for book in books: | ||
print(book.title, book.author, book.year) | ||
else: | ||
Book.seed() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
|
||
#from app.db import BaseModel | ||
# | ||
#class Login(BaseModel): | ||
# | ||
# SHEET_NAME = "logins" | ||
# | ||
# COLUMNS = ["email", "verified", "first_name", "last_name", "profile_photo_url"] | ||
# | ||
from app.db import BaseModel | ||
|
||
class Login(BaseModel): | ||
|
||
SHEET_NAME = "logins" | ||
|
||
COLUMNS = ["email", "verified", "first_name", "last_name", "profile_photo_url"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from flask import Blueprint, render_template, current_app #, session | ||
|
||
from app.models.book import Book | ||
|
||
book_routes = Blueprint("book_routes", __name__) | ||
|
||
@book_routes.route("/books") | ||
def books(): | ||
books = Book.all() | ||
return render_template("books.html", books=books) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{% extends "bootstrap_5_layout.html" %} | ||
{% set page_title = "Books Page" %} | ||
{% set active_page = "books" %} | ||
|
||
{% block content %} | ||
|
||
<h1>Books</h1> | ||
|
||
<p class="lead">This is the books page</p> | ||
|
||
{% if books|length > 0 %} | ||
|
||
<!--div class="container"--> | ||
<ol> | ||
{% for book in books %} | ||
<li>{{ book.title }} | {{ book.author }}</li> | ||
{% endfor %} | ||
</ol> | ||
<!--/div--> | ||
|
||
{% else %} | ||
|
||
<p>Oops, no books found.</p> | ||
|
||
{% endif %} | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters