Skip to content

pranitcode/Shorturl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

URL Shortener Service

A simple URL shortener service built with FastAPI.

Features

  • Shorten a long URL
  • Redirect using short URL
  • Track number of clicks
  • In-memory storage (no database)

Setup Instructions

1. Clone repository

git clone cd url-shortener

2. Create virtual environment

python -m venv venv source venv/bin/activate # Linux/Mac venv\Scripts\activate # Windows

3. Install dependencies

pip install -r requirements.txt

4. Run the server

uvicorn app.main:app --reload

Server will start at: http://localhost:8000


API Usage

1. Shorten URL

curl -X POST "http://localhost:8000/shorten"
-H "Content-Type: application/json"
-d '{"url":"https://www.google.com"}'

Response: { "short_url": "http://localhost:8000/Ab3xYz" }


2. Redirect

Open in browser: http://localhost:8000/Ab3xYz


3. Get Stats

curl http://localhost:8000/stats/Ab3xYz

Response: { "original_url": "https://www.google.com", "clicks": 3 }

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages