skip to navigation
skip to content

Not Logged In

Flask-Shorteners 0.3

Flask Extension for some popular shorteners

Flask-Shorteners
================

![Build Status]https://api.travis-ci.org/ellisonleao/Flask-Shorteners.png
[![Coverage
Status]https://coveralls.io/repos/ellisonleao/Flask-Shorteners/badge.png]https://coveralls.io/r/ellisonleao/Flask-Shorteners

Flask Extension for some popular shorteners.

## Usage

Create an Flask application then puth a single engine config. If the
engine uses an api key and a login, they shall be provided as well

Shorteners implemented so far:

## Googl Shortener

No login or api key needed

from flask import Flask
from flask.ext.shorteners import Shortener

app = Flask(__name__)
app.config['SHORTENER_ENGINE'] = 'GoogleShortener'
url = 'http://www.google.com'
shortener = Shortener(app)
print "My short url is {}".format(shortener.short(url))

# expanding
url = 'http://goo.gl/SsadY'
shortener = Shortener(app)
print "My long url is {}".format(shortener.expand(url))


## Bit.ly

API Key and login configs needed

from flask import Flask
from flask.ext.shorteners import Shortener

app = Flask(__name__)

# For Bit.ly you HAVE to pass the login and api key
app.config['SHORTENER_ENGINE'] = 'BitlyShortener'
app.config['BITLY_LOGIN'] = 'MY_LOGIN'
app.config['BITLY_API_KEY'] = 'MY_API_KEY'

url = 'http://www.google.com'
shortener = Shortener(app)
print "My short url is {}".format(shortener.short(url))

# expanding
url = 'http://bit.ly/AvGsb'
shortener = Shortener(app)
print "My long url is {}".format(shortener.expand(url))

## TinyURL Shortener

No login or api key needed

from flask import Flask
from flask.ext.shorteners import Shortener

app = Flask(__name__)
app.config['SHORTENER_ENGINE'] = 'TinyurlShortener'
url = 'http://www.google.com'
shortener = Shortener(app)
print "My short url is {}".format(shortener.short(url))

# expanding
url = 'http://tinyurl.com/ycus76'
shortener = Shortener(app)
print "My long url is {}".format(shortener.expand(url))


You can see a nice example on [the test
file]https://github.com/ellisonleao/Flask-Shorteners/blob/master/example.py  
File Type Py Version Uploaded on Size
Flask-Shorteners-0.3.tar.gz (md5) Source 2013-11-06 2KB
  • Downloads (All Versions):
  • 2 downloads in the last day
  • 19 downloads in the last week
  • 168 downloads in the last month