forked from joshthecoder/shorty-python
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.py
25 lines (18 loc) · 765 Bytes
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import shorty
# A long url that needs to be shorten.
url = 'http://test.com/a/long/url/that/needs/to/be/shorten'
# The service to use for shortening the URL
# see README for list of supported services.
# For this example we will use the sandbox service
# which stores the links locally in memory.
service = 'sandbox'
# Pass in the service and long url to get a tiny url.
tinyurl = shorty.shrink(service, url)
# You could also access a global instance of the service directly.
tinyurl = shorty.sandbox.shrink(url)
# If you want a new instance of the service.
mysandbox = shorty.Sandbox()
mysandbox.shrink(url)
# If you require a list of all supported services
# for displaying in your UI as a dropdown menu or such
supported_services = shorty.services.keys()