Skip to content

Latest commit

 

History

History
81 lines (60 loc) · 2.69 KB

README.md

File metadata and controls

81 lines (60 loc) · 2.69 KB

Book Ratings

File: import.py

functions

  • create_tables

    • Input : SCHEMA.sql ( for basic table structure )
    • Output : Generate table present in SCHEMA.sql
  • get_books_data ( generator function)

    • Input : books.csv ( for list of isbn required for API request)
    • Output : yields information about books fetched from GOODREADS API
  • insert_books

    • Input : Uses book data yielded by get_books_data
    • Output : Inserts book data in Database at heroku

File: application.py

View_Functions

  • index(page=1) :
    • Path = [ '/' , '/page/int:page' ]
    • Returns index.html page.
  • search(page=1) :
    • Path = [ '/search' , '/search/page/int:page' ]
    • Returns search.html page or Redirects to login view function.
  • register() :
    • Path = '/register'
    • Returns forms.html page or Redirects to login view function.
  • login() :
    • Path = '/login'
    • Returns forms.html page.
  • logout() :
    • Path = '/logout'
    • Redirects to index view function.
  • book(isbn) :
    • Path = '/book/string:isbn'
    • Returns book.html page.
  • post_reviews() :
    • Path = '/post'
    • Redirects book view function.
  • book_info(isbn) :
    • Path = '/api/string:isbn'
    • Returns JSON response.

Other Functions

  • load_loggedin_user() - loads logged in user if any. ( called before every request )
  • login_required(view) - protects routes which require authorization. ( called before any protected view ) Protected Views - [ 'search', 'post_review' ]

Dir: Templates

  • macros.html - Contains macros used as module only.

    • card(book, flag=True) : Used in book.html
    • form(title, hrefs, msg) : Used in forms.html
    • paginateBooks(endpoint, books, page, item=None) : Used in search.html and index.html
  • layout.html - Contains basic layout used as base for all pages.

  • index.html - Home page

  • forms.html - Register and Login pages

  • search.html - Search result page

  • book.html - Book page

  • error.html - Error page

Dir: Static

  • master.css - Contains styles for all pages.

Other Files

  • books.csv : Contains basic information about 5000 books used to get data about books in import.py.
  • requirements.txt : Contains requirements of project meant o be installed by pip install -r requirements.txt.
  • runtime.txt : Contains python runtime required for deployment to heroku.
  • Procfile : Contains init info for deployment to heroku.