GithubHelp home page GithubHelp logo

hello-urld's Introduction

Welcome to Hello, URLd!


Quick Start Guide

Prerequisites:

Docker & Docker compose 

Building the app

Start the docker daemon: 

sudo systemctl start docker


In your terminal, inside the root directory of the project run: 

docker compose up --build 

You can now access the app by typing localhost in your browser, and visiting it. 

Accessing your short URLs:

To visit the short url, in your browser visit localhost/shorty/<yourShortUrl>

Running the unit tests:

In your terminal run pip3 install unittest
python3 -m unittest discover tests

For reference, the API Specification:

Create a new short URL for a given original URL.

Request

POST /shorten

Parameters

original_url: The original URL to be shortened. (required) short_url: The desired short URL. If not provided, a unique short URL will be generated. (optional)

Example:

{
  "original_url": "https://www.example.com",
  "short_url": "abc123"
}

Response

Success Status code: 201 Created

{
  "short_url": "abc123"
}

Error

Status code: 400 Bad Request

{
  "error": "Short URL is already in use"
}

Redirect

Redirect the user to the original URL when the short URL is accessed.

Request

GET /{short_url}

Parameters

short_url: The short URL. (required) Example

GET /abc123

Response

Success
Status code: 302 Found

Location header: The original URL.

Analytics

Retrieve analytics data for a specific short URL.

Request

GET /analytics/{short_url}

Parameters

short_url: The short URL. (required)

Example:

GET /analytics/abc123

Response

Success
Status code: 200 OK
{
  "usage": 0,
  "creation_time": 1617151681.356944
}

Error

Status code: 404 Not Found
{
  "error": "Short URL not found"
}

Delete URL

Delete a short URL.

Request

DELETE /modify/{short_url}

Parameters

short_url: The short URL. (required) Example

DELETE /modify/abc123

Response

Success
Status code: 200 OK
{
  "message": "Short URL deleted successfully"
}

Error

Status code: 404 Not Found
{
  "error": "Short URL not found"
}

hello-urld's People

Contributors

dylanp12 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.