cb5beaa5c8
Signed-off-by: Snehit Sah <snehitsah@protonmail.com>
1.1 KiB
1.1 KiB
simple link shortener
First run
Set up environment
python -m venv env
source env/bin/activate
pip install Flask
To create database, run in a python shell in project directory
import app
app.init_db()
Running
python app.py
Using
Creating short link
curl -X "POST" localhost:5000 -d "url=https://ref.snehit.dev/packaging/what-is-packaging.html"
This returns the shortcode and id.
{
"id": 84407458,
"shortcode": "nqfily",
"url": "https://ref.snehit.dev/packaging/what-is-packaging.html"
}
idis required to later delete the short urlshortcodeis the actual route- eg. in this case,
http://127.0.0.1:5000/nqfilywill take you tohttps://ref.snehit.dev/packaging/what-is-packaging.html
- eg. in this case,
Deleting short link
With the id you get for short links you create, run this.
curl -X "DELETE" 127.0.0.1:5000 -d "id=84407458"
This returns either success or failure, depending on whether the id exists.
{ "msg": "successfully deleted", "status": 200 }
{ "msg": "forbidden", "status": 403 }