This document provides technical documentation for the project, including URL examples, instructions for running tests, and steps for setting up the project using Docker.
The project includes the following URLs:
-
API for creating short URLs:
- Endpoint:
/api
- Method: POST
- Payload:
{"original_url": "https://www.example.com"}
- Response:
{"original_url": "https://www.example.com", "short_url": "http://localhost:8000/abcd"}
- Endpoint:
-
Redirection to original URL:
- Endpoint:
/<str:short_code>
- Method: GET
- Example:
/abcd
(whereabcd
is the short code) - Response: Redirects to the original URL associated with the short code.
- Endpoint:
-
Web page for creating short URLs:
- Endpoint:
/
- Method: GET
- Renders a form where users can enter the original URL and submit it to generate a short URL.
- Endpoint:
To run the tests for this project, follow these steps:
-
Make sure you have the project dependencies installed. You can install them using the following command:
pip install -r requirements.txt
-
Open a terminal or command prompt and navigate to the project's root directory.
-
Run the following command to execute the tests:
python manage.py test
Run the following command to build and run the Docker containers:
docker-compose up
- Run the following command to apply migrations
python manage.py migrate
- Run the following command for run server
python manage.py runserver