Files
flyingcakes cb5beaa5c8 readme
Signed-off-by: Snehit Sah <snehitsah@protonmail.com>
2025-01-08 20:55:39 +05:30

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

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"
}
  • id is required to later delete the short url
  • shortcode is the actual route
    • eg. in this case, http://127.0.0.1:5000/nqfily will take you to https://ref.snehit.dev/packaging/what-is-packaging.html

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 }