Sign inSign up

chand1012/link-shorten

By chand1012

•Updated about 5 years ago

Python Temporary URL Shortener

Image
0

225

chand1012/link-shorten repository overview

⁠Python Temporary URL Shortener

  • All links last 24 hours.
    • The ability to change that length of time will be coming in the near future.
  • Can be hosted as open API or an API with a single key.
  • Can change the base URL redirect. Currently no support for displaying a web page.
  • Uses Redis for high speed links.
  • Will eventually support custom links

⁠To run

Requires Docker⁠ and Docker Compose⁠.

  1. (Optional) Copy example.env⁠ to .env. Change the variables as you see fit. If you don't require a base redirect nor an API key, you can skip this step.
  2. Run docker-compose up --build -d
  3. Use it.

⁠Usage

Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> test_data = {'link': 'https://www.riverways.app/'}
>>> resp = requests.post('http://127.0.0.1:5000/new', json=test_data)
>>> resp.json()
{'link': 'https://www.riverways.app/', 'expire': 86400, 'resetExpireOnClick': False, 'id': '2XVWK8ZI'}

If the environment variable APIKEY is specified.

>>> header = {'X-Api-Key': 'Your-api-key-here'}
>>> resp = requests.post('http://127.0.0.1:5000/new', json=test_data, headers=header)
>>> resp.json()
{'link': 'https://www.riverways.app/', 'expire': 86400, 'resetExpireOnClick': False, 'id': 'loD4MbMc'}

Tag summary

Content type

Image

Digest

Size

372.2 MB

Last updated

about 5 years ago

docker pull chand1012/link-shorten