Giter VIP home page Giter VIP logo

url-shortener's Introduction

Project: url-shortener

Description

Small python project for URL shortener

โš ๏ธ Security Warning

  • 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

Requirements

  • Python 3.7.6
  • Sqlite
  • Install python packages dependencies pip3 install -r requirements.txt

Specifications

  • 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.

Run

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

Future improvements

  • 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.

url-shortener's People

Contributors

juangm avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.