Skip to content

MrNicolass/Library-with-Flask

Repository files navigation

N1 - Web Library with Flask

Static Badge Static BadgeStatic BadgeStatic Badge

Summary

It's a simple website developed with pure Python (API), HTML and CSS (design) in order to learn how API's works; Was proposed as test (N1 = first grade), consisting in one of three notes we've the semester of software engineering degree of Católica University in Jaraguá do Sul, Brazil.

What's the scope and its limitations?

For grade N1, we will create user management and a login screen (without using JWT tokens).

You will need to implement:
(There's a file named requirements.py that contains all extensions installed!)

  1. Database Table(initdb should create the user table):
    1. The user table should have the following fields:
      • id;
      • login (must be the email);
      • password;
      • real name;
      • user creation date;
      • status (active/blocked);
      • last update date of the user.
  2. Create endpoints to perform CRUD operations on the table:
    1. When creating the user, the password must be encrypted using a one-way method (it should not be possible to decrypt the password);
    2. It should NOT be allowed to create users with the same login. When registering, data validation should occur. This validation can happen at the time of data submission, there's no need to validate when leaving the field;
    3. When registering the user, validation of the login should occur to ensure that the chosen login is an email;
    4. When creating the user, the user creation date should be filled with the current date;
    5. When making any changes to the user, the last update date should be filled with the date of the record change (the creation date should remain unchanged);
    6. Users CANNOT be deleted, only blocked.
  3. Create a template for user management (the CRUD operations above should be done via a graphical interface):
    1. Remember that "deletion" will only mark the user as blocked.
  4. Create a login screen template, so that the user can access the system. It should be available at an endpoint /login, and accessible from the top navigation bar of the service:
    1. If the user is blocked, login should not be allowed. A message should be displayed on the screen informing the user of the fact;
    2. If the user is successfully authenticated (login and password are correct), the user should be redirected to a homepage (of your choice);
    3. For now, other endpoints can be accessed directly, routes will not be protected at this stage of the assignment.

Project Setup

We need a few things to run this simple project, that are:

  1. Download VScode IDE if you don't have installed;
  2. Install Python last version or above 3.0 and reboot your pc;
  3. Install SQLite3 last version or above 3.40.0 and reboot your pc;
  4. Download the project .zip or clone it with GitHub, extract all folders in one folder of your choice in your PC;
  5. Inside VScode with the project folder open, click CTRL + SHIFT + ` or type in VScode search bar >Terminal: create new terminal and press Enter;
  6. With terminal open, install this libraries using the syntax below, just copy and paste in terminal:
    1. Instead of downloading all libraries by hand, you can change requirements.py extension from .py to .txt and use the command pip install -r requirements.txt to download all automatic;
    2. pip install flask;
    3. pip install bcrypt;
    4. pip install pysqlite3;
    5. pip install flask_dance;
    6. pip install flask-email;
    7. pip install python-dotenv;
    8. pip install flask-session;
    9. pip install flask-babel.
  7. Now, just open main.py and run it with, to run the server you can use two methods:
    1. You can install the VScode extension Code Runner, with the file open and extension installed, use shortcut Ctrl + Alt + N to run;
    2. In the terminal, make sure you are in the right directory and then type: python main.py to start server;
  8. The server/application already have a database file with some data (database.db), but if you want to start from zero, exclude database.db file and then access the route /initdb to create a new one with all tables and no data inside;
  9. Create a .env file with the parameters below:
    
            GOOGLE_CLIENT_ID="your_Google_API_id"
            GOOGLE_CLIENT_SECRET="your_Google_client_secret"
            GITHUB_CLIENT_ID="your_GitHub_API_id"
            GITHUB_CLIENT_SECRET="your_GitHub_API_password"
            MAIL_USERNAME="your_e-mail"
            MAIL_PASSWORD="your_Google_API_password"
          
  10. Enjoy exploring!

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •