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.
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
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
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>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.