URL Shortner is a service that shortens long URL into short URLS that we can easily share and remember. This mini-project is a complete backend implementation of URL Shortner that is built using
- FastAPI (Python)
- Redis Cache
- MongoDB
- Shorten a long URL to a short URL
- Paste the short URL in browser to visit the actual site (long URL)
- Delete the short URL
- Create a custom short URL that anyone can easily remember
The project was an attempt to solve the Coding Challenge from John Crickett
- Install Docker
- Install Redis Cache
docker run -d --name redis-container -p 6379:6379 redis:latest
- Install Mongo db
docker run -d --name mongodb-container -p 27017:27017 \
-e MONGO_INITDB_ROOT_USERNAME=admin \
-e MONGO_INITDB_ROOT_PASSWORD=admin \
mongo:latest
-
create a virtual environment. Follow this simple guide to create a virtual environment
-
install the prerequisites
pip install -r requirements.txt
- Run the app using following command
uvicorn api:app --reload
- Shorten a URL
curl -X POST -H "Content-Type: application/json" -d '{"url": "https://www.example.com"}' http://localhost:8000/shorten
- Use the short URL
- Open a browser
- paste the short URL
- Notice that the app redirects the short URL to long URLs web page
- Delete a short URL
curl -X DELETE http://localhost:8000/yCypqR+ -i
Note: make sure to use the app generated hash above
- Once the URL is removed, try the short URL in web browser, it won't redirect to the original URL.
- Implement custom hashing
- Implement a front end that consumes the APIs
- DockerFile and CI/CD Implementation
Plugin | README |
---|---|
Profile | |
GitHub | Profile |