Giter Club home page Giter Club logo

url_shortner's Introduction

url_shortner

This application accepts the URL as input and shortens the URL and returns to the user. This application is implemented as docker image. Kindly follow below steps to setup and run the application. Apllication also checks if the provided url is already shortened, if so it returns the shortened URL. All te data is maintained in text file named url-data.json. Every time api request is recieved the it will be updated in data file.

Setting up application

1. Clone the repositiry
   git clone
2. Traverse insede url-shortner directory
   cd url_shortner
3. Build docker image
   docker build -t url_shortner:latest .
4. Once the image build is complete you can verify using below command
  docker images
  output:
  REPOSITORY                              TAG             IMAGE ID       CREATED         SIZE
  url_shortner                            latest          d772fc233276   2 minutes ago   449MB
5. Run docker container from image
  docker run -p 5000:5000 url-shortner:latest
  output:
  * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
  * Restarting with stat
  * Debugger is active!
  * Debugger PIN: 247-353-832

using applicaion

Run below api from the machine where the container is running
curl http://0.0.0.0:5000/url_shortner/url=

Example: curl http://0.0.0.0:5000/url_shortner/url=google.com

Testing

Case1:
Description: if you just enter below URl it will describe what is this app and how to use
enter URL :  curl http://0.0.0.0:5000/
output:
+++++++++Welcome to free URL shortening service+++++++++
         please enter below api call to shorten your URL
         curl http://0.0.0.0:5000/url_shortner/url=google.com 

Case2: Description: pass on some URL and it return shortened URL enter URL : curl http://0.0.0.0:5000/url_shortner/url=yahoo.com output:

 http://0.0.0.0:5000/xjmb38
Case3:
Description: Re-enter the same URL
enter URL :  curl http://0.0.0.0:5000/url_shortner/url=yahoo.com
output:
URL alraedy exists, the shortned URL is http://0.0.0.0:5000/xjmb38
Case4:
Description: Error handling enter wrong url
enter url: curl http://0.0.0.0:5000/ur
output:
<title>404 Not Found</title>

Not Found

The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

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.