Make sure that you are inside bakend
folder to proceed with the following information.
This application provides 2 routes to:
- List current history
- Save an URL into the history table
This application is testable with an API tester like Postman.
-
The project is organized with two main apps:
- core: manages the migrations, models and their tests for all project;
- history: manages the logic for history records with urls, serializers, views and API tests.
Please make sure that you have:
- Python
- Pip
- A dependency manager, such pipenv
To use a new shell that ensures all commands have access to installed packages use
$ pipenv shell
Then, run the following commands. The project is inside video-player/backend
The existing dependencies in this API:
- Django >=
3.0.8
, but less than3.1.0
- Django Rest Framework >=
3.11.0
, but less than3.12.0
- Flake8 >=
3.8.3
, but less than3.9.0
- Factory-boy >=
2.12.0
, but less than2.13.0
- Django CORS Headers >=
3.4.0
, but less than3.5.0
# to run requirements
$ pip install -r requirements.txt
# to create the migrations according the existing models
$ python manage.py makemigrations
# to trigger the migrations
$ python manage.py migrate
The data is persisted with a db.sqlite3
file that is created when you run the migrations commands.
$ python manage.py runserver
One note: the received YouTube video URLs must have one of the following substrings:
youtube.com/watch?
youtu.be
Open your favorite browser and write
http://127.0.0.1:8000/api/history/
# to run tests
$ python manage.py test **/*/.
- Open Postman App
GET
- check if the verb is GET
- Enter the previous address in address bar
- If you have some URLs already persisted, they will be returned
POST