https://github.com/arvind-4/url-shortner
Url shortner service using Neon db and Django!
https://github.com/arvind-4/url-shortner
django neondb postgres vercel
Last synced: 10 days ago
JSON representation
Url shortner service using Neon db and Django!
- Host: GitHub
- URL: https://github.com/arvind-4/url-shortner
- Owner: arvind-4
- Created: 2024-11-18T02:23:52.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-20T16:09:04.000Z (about 1 year ago)
- Last Synced: 2025-05-15T19:11:24.708Z (8 months ago)
- Topics: django, neondb, postgres, vercel
- Language: Python
- Homepage: https://awesomeurlshortner.vercel.app
- Size: 63.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Url Shortner
A simple URL shortener built using Django and PostgreSQL.
## Features
- Shorten URLs
- Redirect to original URLs
- Get top visited domains
- Get metrics
## Local Setup (Docker)
1. Clone the repository
2. Run `docker compose up --build` to start the application
## Local Setup
1. Clone the repo
2. copy the contents of `.env.docker` to `.env`.
3. Install the requirements from `requirements.txt`.
4. Run the dev server by the command `python manage.py runserver`
## Try the api!
```bash
curl --location 'https://awesomeurlshortner.vercel.app/shorten/' \
--header 'Content-Type: application/json' \
--data '{
"url": "facebook.com"
}'
```
## Url Routes:
- **`shorten/` (POST)**: Takes a URL in the request body, validates it, creates or retrieves a shortened URL, and returns the shortened URL in a JSON response.
- **`metrics/` (GET)**: Returns a JSON response with the top 3 most common domains from all shortened URLs in the database.
- **`/` (GET)**: Takes a shortcode from the URL path, looks it up in the database, and redirects to the original URL associated with that shortcode.