Giter Club home page Giter Club logo

url_shortener's Introduction

url_shortener

pythonic URL shortening service Dandy Martin

Description

URLSHORTENER is an importable library that generates shortened references to longer URLS.

  • URL storage service is customizable depending on preference with adherence to the URLTABSTRACT abstract class' function calls.
  • In order to use a custom storage service, build your own urltable.py with URLTABLE class object, and wrap your storage and retrieval calls according to the URLTABSTRACT function calls.
  • Updated to utilize an ascii-based bijective function to randomly generate hash keys whose characters fall in the range a-zA-Z0-9, and appending their integer values together instead of simply summing them - Vastly increasing the range of keys available, and minimizing risk of collision.
  • Additionally allows custom hash key range (variable from 1-N)
  • By default, an explicit, dynamic hash-table implementation is already provided... (I realize Python already has a dictionary that can be used instead, this was more fun). Simply follow the Quick Start Guide to get started.

Features

  • Importable Class-based structure
  • Abstract class for 'API' guidance

Quick Start Guide

  1. Import the shorten.py URLSHORTENER class
    from shorten import URLSHORTENER
  1. Initialize URLSHORTENER with your host, table size, and url-object time-to-live values
    myshortener = URLSHORTENER('www.myhost[.]com', 999, 3)
  1. Generate a shortened URL with a call to get_short_url function, passing the long_url. If your host is http unsecured, set the second optional value to True
    long_url = 'www.somehost[.]net/there/is/a/whole/bunch/of?what'
    short_url = myshortener.get_short_url(long_url) # if secured
    us_short_url = myshortener.get_short_url(long_url, http=True)  # if unsecured

    >>> print short_url
    'https://www.myhost[.]com/jt104'
    >>> print us_short_url
    'http://www.myhost[.]com/jt104'
  1. Similarly, in order to retrieve the long-version of your url, simply call get_long_url with the shortened url value
    long_url = myshortener.get_long_url(short_url)

    >>> print long_url
    'www.somehost[.]net/there/is/a/whole/bunch/of?what'

Requirements

build requires python stdlib imports: struct, random, and datetime

Special requirements are a custom urltable.py classfile with a URLTABLE class object though a default has been provided

url_shortener's People

Contributors

dandysrt avatar

Watchers

Taylor Flatt 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.