Skip to content

ferygood/shortURL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ShortURL

This is a server for generating short URL. Users first provide their original long URL and this API generate a shorter one for users. Later on, users can use this URL to visit their origin website.

Key techniques used

  • Framework: FastAPI
  • Database: MongoDB
  • Container: Docker
  • Unit test: pytest

Features

  • Enter long URL and generate short URL
  • Use short URL to redirect to long URL
  • Copy the generated short URL

Prerequisite

If you run this app locally, you will need follow the installation: MongoDB. After downloading, I use macOS as an example:

  1. Start MongoDB
brew services start mongodb-community
  1. Stop MongoDB
brew services stop mongodb-community

Installation

  1. Clone this repository
    git clone https://github.com/ferygood/shortURL.git
    cd shortURL
  2. Create a virtual environment and install dependencies
    python -m venv venv
    source venv/bin/activate
    pip install -r requirements.txt

How to use

Run the app

uvicorn main:app --reload

After running the app, you can paste http://127.0.0.1:8000/ in your browser:

you can also use tools such as cURL to interact with the api For example:

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

use the shorten url. Let says you receive a short URL: abcd123,

curl -X GET "http://localhost:8000/abcd123"

About

An api that can shorten long url for users

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published