Application for shortening the URL
$ create database DBNAME;
and setup DB-url for accessing database for application
$ export DATABASE_URL=postgresql+psycopg2://{user}:{pass}@{DB_URL}/{DBNAME}
replace username, password, DB_URL, DBNAME with your Local Environment Config.
Go to Project Folder
$ sudo pip3 install -r requirements.txt
$ python3 manage.py create_db
$ python3 manage.py db init
$ python3 manage.py db migrate
$ gunicorn manage:app
For testing Demo Application is live on Heroku
- For creating tiny url
$ curl --location --request POST 'https://koshex.herokuapp.com/tiny/create' \
--header 'Content-Type: application/json' \
--data-raw '{
"url": "https://www.google.com/search?channel=fs&client=ubuntu&q=access+inherited+class+value+in+python"
}'
- For searching keywords 'python' in already shortened url/
$ curl --location --request GET 'https://koshex.herokuapp.com//tiny/search?key=python'
- For Fetching metadata of stored url - pass shorten base_path of url to route.
$ curl --location --request GET 'https://koshex.herokuapp.com/tiny/agkcpj'
- For Redirecting from short url
$ curl --location --request GET 'https://koshex.herokuapp.com/agkcpj'