Small python project for URL shortener
- This program was created for educational purposes.
- This program is not protected against ๐
sql injection
- If the script is added to a web service, the service will filter the inputs to avoid this issue
- Python 3.7.6
- Sqlite
- Install python packages dependencies
pip3 install -r requirements.txt
-
Shorten a URL:
- Input: A regular URL (not from applau.se domain)
- Output: A shortened URL (use only ten digits, 26 lowercase characters, 26 uppercase characters) of extra length 2 from a given link example: applau.se/5s)
- Handle the case that the 2-character length is running out of choices by retiring the shortened URL that has not been called for the longest time.
-
Retrieve a URL:
- Input: A shortened URL (from applau.se domain)
- Output: Retrieve the original URL.
-
Basic admin:
- Show all stored shortened URLs (including shortened URL, original URL, call count and latest call time) and sort by call count.
To run the url-shortener locally, you just need to install the requirements and execute:
python3 shortener.py
The program has the following options implemented:
- url: provide a url to short or unshort.
- setup_db: create table in DB and erase previous data if table existed before (only admin)
- show_db: show all the data in the urls table (only admin)
- help: help menu.
- exit: exit the program.
Generate combinations for possible short urls:
- The combinations for the previous specs are already generated in
combinations/encoding.json
file - To regenerate the file just run
python3 combinations/generate_combinations.pyt
Run the tests:
pytest
- Add tests for checking the specs are not being broken when implementing new features.
- Tests for url helper class
- Tests for sqlite helper class
- Tests for simulating real user interaction (based in specs)
- Implement login system with password for the admin service.
- Create a CI to run the tests.
- Implement small web application for the user interface.