Flashcard Django based proect with API and GUI.
Here are the API usage examples using httpie client.
http POST example.com:8000/flashcard/api/v1/api-token-auth/ username='user' password='password'
{
"token": "11111111222223333333333334445"
}
export AUTH="Authorization:Token 11111111222223333333333334445"
http GET example.com:8000/flashcard/api/v1/decks/ "$AUTH"
[
{
"description": "",
"id": 21,
"name": "Misc"
},
{
"description": "",
"id": 17,
"name": "MyEnglish"
}
]
http POST example.com:8000/flashcard/api/v1/decks/ "$AUTH" name='MyDeck'
{
"description": "",
"id": 22,
"name": "MyDeck"
}
http example.com:8000/flashcard/api/v1/decks/7/cards/ "$AUTH"
[
{
"answer": "That's their kitchen.\r\nThe kitchen is huge.\r\nNowadays, it's hard to find kitchens like this.",
"consec_correct_answers": 1,
"easiness": 3.28,
"id": 31,
"question": "Это кухня.\r\nОчень большая.\r\nНелегко найти дом с такой кухней."
},
{
"answer": "- Do you know why he's not coming? - I don't care.\r\nIt's because he hasn't spoken to me since I came out.\r\nHe didn't know before that?",
"consec_correct_answers": 1,
"easiness": 3.44,
"id": 37,
"question": "Вы знаете, почему он не приедет?\r\nМне все равно. Потому, что он не разговаривает со мной. С тех пор, как я открылся ему.\r\nОн не знал до этого?"
}
]
http POST example.com:8000/flashcard/api/v1/decks/1/cards/ "$AUTH" "question"="How are you?" "answer"="Fine!"
{
"answer": "Fine!",
"consec_correct_answers": 0,
"easiness": 2.5,
"id": 39,
"question": "How are you?"
}
http example.com:8000/flashcard/api/v1/decks/7/cards/?days=N "$AUTH"
[
{
"answer": "Who do you think gave Kai the idea to put Elena in that sleeping beauty coma?",
"consec_correct_answers": 1,
"easiness": 2.72,
"id": 24,
"question": "Как ты думаешь, кто подал Каю идею уложить Елену в эту спящую кому?"
},
{
"answer": "Looks like a Bentley.",
"consec_correct_answers": 1,
"easiness": 3.6,
"id": 25,
"question": "Выглядит, как Бентли."
}
]
- python 3
- dangorestframework
- bootstrap
# clone repo
git clone https://github.com/zserg/flashcard.git
# create virtualenv, activate it
cd flashcard
virtualenv -p python3 venv
. venv/bin/activate
# install dependencies
pip install -r requirements/local.txt
sudo -u postgres psql
# run commands in psql
create database <base>;
create user <username> with password <password>;
grant all on database <base> to <username>;
# create secret key
python -c 'import random; import string; print("".join([random.SystemRandom().choice(string.digits + string.ascii_letters + string.punctuation) for i in range(100)]))'
# create .env file with the following content:
DEBUG=on
ALLOWED_HOSTS='your_host_name'
SECRET_KEY='your_secret_key'
DATABASE_URL=psql://<ursername>:<password>@127.0.0.1:port/<base>
#migrate database
DJANGO_READ_DOT_ENV_FILE=True ./manage.py migrate
# create superuser
DJANGO_READ_DOT_ENV_FILE=True ./manage.py createsuperuser
DJANGO_READ_DOT_ENV_FILE=True ./manage.py runserver