This project helps to shorten URL links (generate bitlinks) and to get clicks for already shortened links (bitlinks) by using Bitly - URL shortening service and a link management platform.
-
Firstly you have to install python and pip (package-management system) if it hasn't been already installed.
-
Create virtual enviorment with its own independent set of packages using virtualenv/venv. It'll help you to isolate the project from the packages located in the base enviornment.
-
Install all of the packages used in this project, in your virtual enviorment which you've created on the step 2. Use the
requirements.txtfile to install packages:pip install -r requirements.txt -
Also you need to create an account on bitly.com and generate your own access token, which would be used in The Bitly API.
-
Creat an
.envfile and locate it in te same directory where your project andmain.pyfile are. Copy and and append your access token to.envfile like this:BITLY_TOKEN=paste_here_your_token_from_step_5 -
Don't forget to add
.envto your.gitignoreif you are going to put project on GIT.
- Shortening URL:
>>> root@ubuntu:~$ main.py https://www.google.com/
Your shortened link for https://www.google.com/ is: https://bit.ly/3asd3esv- Getting count of clicks for bitlink:
>>> root@ubuntu:~$ main.py https://bit.ly/3asd3esv
Count of clicks on https://bit.ly/3asd3esv is: 0This code was written for educational purposes.