Skip to content

vscncls/pyShortURL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyShortURL

pyShortURL is a REST Api used for shortening urls

Usage

There are two options you can take, use a custom url or generate a random one

Random aproach

Make a POST to /random. include a JSON formatted like bellow.

{
  "url": "https://example.com/0"
}

The above will return

{
  "isError": false,
  "shortenedUrl": "SaBopD",
  "url": "https://example.com/0"
}

To get the original URL, make a GET to /, include a JSON formatted like bellow.

{
  "shortenedUrl": "testeeeee"
}

The above will return

{
  "isError": false,
  "shortenedUrl": "testeeeee",
  "url": "google.comgergregre"
}

Custom aproach

Make a post request to the /custom endpoint. include a JSON formatted like bellow

{
  "url": "https://example.com/1",
  "custom_url": "test"
}

The above will return a JSON

{
  "msg": "ok",
  "url": "https://example.com/1",
  "custom_url": "test"
}

To get the original URL, make a GET to /, include a JSON formatted like bellow.

{
  "shortenedUrl": "test"
}

The above will return

{
  "isError": false,
  "shortenedUrl": "testeeeee",
  "url": "https://example.com/1"
}

Setup

virtualenv pyShortUrl

or

python -m virtualenv pyShortUrl

Clone the repo

mkdir app
git clone https://github.com/ramenbroth/pyShortURL app
cd app/

Activate your virtual environment

source ../bin/activate.fish # replace .fish according to the shell you're using

Then install the requirements

pip install -r requirements.txt

And make sure to create the necessary tables

Open a python shell and run

>>>import api
>>>api.setup_database()

After that just run

flask run

About

URL shortner built with Flask

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages