{ "info": { "author": "Doubletapp", "author_email": "info@doubletapp.ru", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 3.5", "Topic :: Internet :: WWW/HTTP" ], "description": "django-url-shortening\n=====================\n\nA custom URL shortening app for Django with API.\n\nUsage\n=====\n\n1. Add ``urlshortening`` app to your ``INSTALLED_APPS`` and do\n ``migrate``\n\n2. Wire up the redirect view by adding to your URLconf\n\n ::\n\n ('^linkshortening/', include('urlshortening.urls'))\n\n3. Add settings (more about parameters further)\n\n ::\n\n INITIAL_URL_LEN = 6\n RETRY_COUNT = 5\n SHORT_URL_PATH = 'http://example.com/short-prefix/'\n REDIRECT_PREFIX = 'r'\n\n4. Now you can use API to make short links\n\n ``POST linkshortening/short/``\n\n With json data ``{\"full_url\": \"http://example.com/a/b/c/d/e\"}``\n\n And get response\n\n ::\n\n {\"data\": {\n \"short_id\": \"123456\",\n \"short_url_path\": \"http://example.com/short-prefix/\"\n }, \"error\": \"\"}\n\n5. You could also use ``urlshortening`` right from code\n\n ::\n\n from urlshortening.models import get_short_url, invalidate_url, get_full_url\n\n ::\n\n url = \"http://example.com/a/b/c/d/e\"\n short_url = get_short_url(url) # Url object\n print(short_url.short_id) # id for short url\n\n ::\n\n full_url = get_full_url(short_url.short_id) # Url object\n print(full_url.url) # \"http://example.com/a/b/c/d/e\"\n\n ::\n\n # You could also invalidate url\n invalidate_url(full_url.short_id)\n\nAPI\n===\n\n**Get short link**\n\n- **URL**\n\n ::\n\n /short/\n\n- **Method:** ``POST``\n\n- **Data Params**\n\n - full\\_url\n\n- **Success Response:**\n\n - **Code:** 200 **Content:**\n ``{ data: { \"short_url_path\": \"000001\" }, error: \"\" }``\n\n- **Error Response:**\n\n - **Code:** 400 **Content:** ``{ error : \"full_url is empty\" }``\n\n - **Code:** 400 **Content:** ``{ error : \"full_url is too long\" }``\n\n**Get full link**\n\n- **URL**\n\n ::\n\n /expand/:short_id/\n\n- **Method:** ``GET``\n\n- **URL Params**\n\n ::\n\n short_id=[string]\n\n- **Success Response:**\n\n - **Code:** 200 **Content:**\n ``{ error : \"\", data: { full_url: \"http://example.com/to-000001\" }}``\n\n- **Error Response:**\n\n - **Code:** 404 **Content:** ``{ error : \"Link is expired\" }``\n\n - **Code:** 404 **Content:** ``{ error : \"Url doesn\\'t exist\" }``\n\n**Get redirect**\n\n- **URL**\n\n ::\n\n /REDIRECT_PREFIX/expand/:short_id/\n\n- **Method:** ``GET``\n\n- **URL Params**\n\n ::\n\n short_id=[string]\n\n- **Success Response:**\n\n - **Code:** 302\n\n- **Error Response:**\n\n - **Code:** 404 **Content:** ``{ error : \"Link is expired\" }``\n\n - **Code:** 404 **Content:** ``{ error : \"Url doesn\\'t exist\" }``\n\n**Invalidate url**\n\n- **URL**\n\n ::\n\n /invalidate/\n\n- **Method:** ``POST``\n\n- **Data Params**\n\n - short\\_id\n\n- **Success Response:**\n\n - **Code:** 200 **Content:**\n ``{ error : \"\", data: { \"short_id\": \"000001\", \"invalidated\": \"true\" } }``\n\n- **Error Response:**\n\n - **Code:** 400 **Content:** ``{ error : \"short_id is empty\" }``\n\n - **Code:** 400 **Content:**\n ``{ error : \"Link is already expired\" }``\n\n - **Code:** 404 **Content:** ``{ error : \"Url doesn\\'t exist\" }``\n\nSettings\n========\n\nAvailable settings are:\n\n- ``INITIAL_URL_LEN``\n\n Initial length of short id for url. Once you get more short id's than\n is possible in all combinations of ``INITIAL_URL_LEN`` symbols it\n will increase by one\n\n- ``RETRY_COUNT``\n\n How many times do we to check before increasing ``INITIAL_URL_LEN``.\n\n- ``SHORT_URL_PATH``\n\n Url that will be returned with ``short_id`` on\n ``POST linkshortening/short/`` request. It might help you to\n construct full url.\n\n- ``REDIRECT_PREFIX``\n\n Select prefix to use redirect links. For example\n ``REDIRECT_PREFIX=\"r\"`` and we get redirect links with format\n ``/r/expand/{short_id}/``", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/doubletapp/django-url-shortening", "keywords": "", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "django-url-shortening", "package_url": "https://pypi.org/project/django-url-shortening/", "platform": "", "project_url": "https://pypi.org/project/django-url-shortening/", "project_urls": { "Homepage": "https://github.com/doubletapp/django-url-shortening" }, "release_url": "https://pypi.org/project/django-url-shortening/1.0.0/", "requires_dist": null, "requires_python": "", "summary": "A URL shortening app for Django.", "version": "1.0.0" }, "last_serial": 3219623, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "9d3d57142a10b49231234ad81d76efe7", "sha256": "5d94c6adc46dd80427e73b1c7433dbd8af240037c9960f778d1fedb6489e9f4e" }, "downloads": -1, "filename": "django-url-shortening-1.0.0.tar.gz", "has_sig": false, "md5_digest": "9d3d57142a10b49231234ad81d76efe7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5623, "upload_time": "2017-10-02T15:45:13", "url": "https://files.pythonhosted.org/packages/cb/88/281ed0e22547a94a6042a53eb639e2b637e6df95f5cfafda8e25d67174a2/django-url-shortening-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9d3d57142a10b49231234ad81d76efe7", "sha256": "5d94c6adc46dd80427e73b1c7433dbd8af240037c9960f778d1fedb6489e9f4e" }, "downloads": -1, "filename": "django-url-shortening-1.0.0.tar.gz", "has_sig": false, "md5_digest": "9d3d57142a10b49231234ad81d76efe7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5623, "upload_time": "2017-10-02T15:45:13", "url": "https://files.pythonhosted.org/packages/cb/88/281ed0e22547a94a6042a53eb639e2b637e6df95f5cfafda8e25d67174a2/django-url-shortening-1.0.0.tar.gz" } ] }