Project completed in CS50W course. Used Goodreads API and Heroku PostgreSQL database.
The project was implemented in PyCharm 2020.1.2 (Professional Edition). Applied technology Flask, Jinja2, JavaScript, HTML5, CSS3 (SASS).
The task can be viewed at the link - Project 1: Books.
The task sounds like this:
«In this project, you’ll build a book review website. Users will be able to register for your website and
then log in using their username and password. Once they log in, they will be able to search for books,
leave reviews for individual books, and see the reviews made by other people. You’ll also use the a third-party
API by Goodreads, another book review website, to pull in ratings from a broader audience. Finally,
users will be able to query for book details and book reviews programmatically via your website’s API.»
Data for connecting to the database is specified in the application.py file. The 10,000 rows Heroku provided for free
was not enough for me, so I temporarily bought the next database plan (10,000,000 rows), which costs $ 9 per month.
After checking my project, I will not pay for the database, so it may not work. In addition, Heroku periodically
changes connection data when using its first tariffs, so the database may stop working before I cancel my
subscription.
-
The file contains a list of libraries used to run the application.
pip3 install -r requirements.txt -
The main file that initializes the application. This file links the application, consisting of different files, into a single whole. Here are the keys to the Heroku database Goodreads URI APIs. To launch the application, use the commands:
set FLASK_APP=application.py flask run -
Project configuration file. Contains the basic settings for the application. Flask_mail settings and so on.
-
File of the main application paths. The basic logic for the application is described here.
Which implements certain functions when navigating to a specific URL. -
Contains helper objects. Here I tried to use the basics of OOP. Uses FlaskForm. Most database queries are described here.
-
This is a file from CS50 Finance. Authorization Check Function. I added the function of checking the extension of the downloaded files to this file and sending a message to the email address.
-
The directory where the application files are located (image, CSS, JS)
-
The main script written in JavaScript. I tried to leave detailed comments, but my knowledge of English is low :(.
My experience in JS is minimal. I was looking for information on Google to implement certain functions.
-
SASS file containing CSS markup for all pages of the application.
-
A directory with 5,000 book covers downloaded! :) (minimum file size)
-
Directory of user images.
-
-
The directory where the HTML markup templates are located. The main layout.html template.
The rest are related to him, thanks to Jinja2 -
Database schema
-
Secret key generation (more)
-
An additional file for debugging, so as not to write commands every time.
-
Program for reading books.csv and subsequent import into Heroku Database
To start use the command:
Set the environment variable DATABASE_URL to be the URI of your database, which you should be able to see from the credentials page on Heroku.
python import.py -
Additional file for downloading book covers and text book descriptions.
Images will be saved in the specified directory. Text and file name will be added to the database.
Set the environment variable DATABASE_URL to be the URI of your database, which you should be able to see from the credentials page on Heroku.
python parc_img_text.py
To use the functions of the site you need to register, indicating the name, surname, email address and password.
Using Bootstrap 4 validation.
Additionally, the function of checking the coincidence of passwords and viewing the entered passwords is implemented.
After entering the data and submitting the form, the server will process the request,
enter the new data into the database and send an email with a link to confirm the mailbox.
If the specified mailbox address is already in use, you will see a message about this.
ATTENTION! The mailbox name is not case sensitive (MyEMail@exaMPLe.com == myemail@example.com), unlike the rest of the fields.
If the user tries to enter the site without confirming the mailbox, the application will not allow this, and the sign in form will offer to re-send the letter.
On the page for re-sending the letter, you need to specify your mailing address. If you specify a mailbox that
is not in the database or it has already been verified, you will receive an error message.
Otherwise, you will receive a letter to the specified mailbox, in which there will be a link with a GET request.
After clicking on the link from the letter, you will automatically activate your account.
After activation, you can log in with your account.
Forgot your password? Do not despair! It can be reset! How? Again through your mailing address.
You need to go to the forgot password link and specify the address of your mailbox. If such an address exists, then
a letter will be sent to you, and on the screen you will see a message
In case of an error, the message will be different!
After clicking on the link from the letter, you will see a form that will allow you to change your password.
When you submit a login form, if you provide an incorrect username or password, you will receive a message about this.
Otherwise, you will be taken to the main page of the site.
-
Personal profile
Pressing
A form of personal information will open before you, which no one sees, except you. The page has your photo, the number of your ratings and reviews. You also have the right to upload a new photo, no larger than 5 MB.
I was not able to test error 413 on either the local or AWS EB server. The @ app.errorhandler (413) handler refuses to process it more details.
In the forms below you can change your password or email. In case of input errors, you will also receive error messages.
If you succeeded in successfully changing the password or email, then you will receive a success message.
The password can be changed by confirming your account by entering the old password. Changing the mailbox address will require confirmation through the new address.
-
Information Button
By clicking on the icon
You will see a window with general statistics showing the number of books, reviews and registered users.
-
The main function is the search! By clicking on the icon
You will see a search box
You can enter isbn. Title, author book. Both fully and partially. Register does not matter at all.
The search form responds to Enter (Numpad Enter), but you can use the search button. By the way, do not worry about the number of books in the search! On the screen you will see a maximum of
20 books on one page and 20 pages. Pages can be switched by ArrayLeft / ArrayRight.The text and image for the books were taken from the goodreads website, using the small Python code I wrote (parc_img_text.py).
I attached this code to the project. I hope that goodreads are not against the use of their materials for educational (and only!) Purposes.If the book already has grades, then the stars will be colored proportionally! Check it out!
-
Log out By clicking on the button on the home page
you will end your session and sign out.
If you want to leave a review about the book, then you can go to its page!
If you have not left a review, then you will see a button that will open the feedback form for you.
IMPORTANT! All fields must be filled!
If you have already left your rating, then this form will not be! I did not give the opportunity to delete my reviews that I left earlier, since “the first word is more expensive than the second” ©
You can leave a response that will be added to others without refreshing the page
nd the overall rating data will also be updated immediately !!! Thanks JSON!
By the way, the text of the books as a result of the search and on the pages of the book is different (in most cases).
Pay attention to the rating of books according to goodreads (API). They are updated every time the page is refreshed.
By the way, we now also have our own API! It is easy to access, go to / api / isbn. Specify the number of the book you selected instead of isbn.
By completing a similar request, you will get such a result.
If you specify an invalid isbn, you will receive an error in the form of JSON and a 404 code for the browser.
Any 404 errors will lead to a redirect to the main page.





















































