Web Application to Learn words and its definitions represented in card front-back form
Front
·
Report Bug
·
Request Feature
Table of Contents
Dzmitry Mikialevich
Konrad Kowalczyk
This is a project of a web application (backend + frontend) which allows users to learn various topics by so-called
“learning cards”.
Front page of such a reversible card contains a word to learn and the back contains description or definition.
Database stores users’ accounts data, their collections of cards and the collections “liked” by them.
- Database:
- Backend:
- Frontend:
Can be found at: router.py
| ADDRESS:://{ } | METHOD | NOTES | REQUEST | RESPONSE |
|---|---|---|---|---|
| api/auth/sign-in | post | Client browser receives a session_id as a cookie | { email: string, password: string } |
HTTP: 200 OK { userName: string userID: int } |
| api/auth/sign-up | post | Client browser receives a session_id as a cookie | { username: string, email: string, password: string } |
HTTP: 201 CREATED { userName: string userID: int } |
| api/auth/sign-out | post | HTTP: 204 NO_CONTENT | ||
| api/auth/current-user | get | Returns logged in user | HTTP: 200 OK { userID: int, userName: string, userEmail: string, userInfo: json } |
|
| api/collections | get | Returns all collections, {page, size} query params | HTTP: 200 OK { total: int, data: [{ is_liked: boolean, collectionID: int, collectionName: string, collectionDescription: json, holderID: int, cardInfo: json }] } |
|
| api/collections/user/{user_id} | get | Returns collections created by user {page, size} query params | HTTP: 200 OK { total: int, data: [{ is_liked: boolean, collectionID: int, collectionName: string, collectionDescription: json, holderID: int, cardInfo: json }] } |
|
| api/collections/{collection_id} | get | Returns single collection | HTTP: 200 OK [ { cardID: int, collectionID: int, cardInside: json, is_watched: boolean } ] |
|
| api/current-user/collections | post | Creates a new collection, login required | { collectionDescription: string collectionName: string } |
HTTP: CREATED |
| api/current-user/collections | delete | Removes a collection, login required, ownership required | { collection_id: int } |
HTTP: NO_CONTENT |
| api/current-user/favourite | get | Returns favourite collections of the user, login required, {page, size} query params | HTTP: 200 OK [ total: int, data: [{ is_liked: boolean, collectionID: int, collectionName: string, collectionDescription: json, holderID: int, cardInfo: json }] } |
|
| api/current-user/favourite/{collection-id} | post | Adds the collection to favourites, login required | HTTP: OK | |
| api/current-user/favourite/{collection-id} | delete | Removes the collection from favourites, login required | HTTP: OK | |
| api/collections/{collection_id} | post | Adds a card to the collection, ownership required | HTTP: OK | |
| api/collections/{collection_id} | delete | Removes a card from the collection, ownership required | HTTP: OK |
To run locally:
- Install and Configure PostgreSQL
- Create POSTGRES variable in config.py file with your database credentials
- Create SECRET_KEY in config.py with securely generated hash:
- bash:
python -c 'import os; print(os.urandom(16))'
- bash:
- Create database by running:
python setup.py
- Run
flask runfrom the root folder
Contents of config.py:
POSTGRES = {
'user': 'UserName',
'pw': 'Password',
'db': 'DatabaseName',
'host': 'hostName',
'port': '5432',
}
SECRET_KEY = "Generated in previous step secret key"def fill_with_data(csv_path,collection_id,column_front,column_back):
import csv
with open("out.txt", "w") as file:
with open(csv_path,newline='') as csv_file:
list_of_rows = csv.reader(csv_file, delimiter=',', quotechar='|')
for row in list_of_rows:
row[column_front] = row[column_front].replace("\"","")
row[column_back] = row[column_back].replace("\"","")
print(row)
json_to_write = {
'front' : row[column_front],
'back' : row[column_back]
}
json_to_write = str(json_to_write).replace("'", "\"")
file.write(f"{collection_id}\t{json_to_write}\n")Distributed under the MIT License. See LICENSE for more information.

