Code Monkey home page Code Monkey logo

url-shortener's Introduction

URL shortener

This service implements an endpoint for generating shortened links. Following endpoints are supported:

Generate site identifier identifying provided URL:

$ curl -XPOST "localhost:5001/api/v1/shorten/https://gooogle.com?format=json"
{"status": "OK", "request_url": "https://gooogle.com", "identifier": 1204225829}

Retrieving URL from provided identifier:

$ curl "localhost:5001/api/v1/lookup/1204225829?format=json"
{"status": "OK", "request_url": "https://gooogle.com", "identifier": "1204225829"}

Performing HTTP redirect when identifier is supplied in apps base path:

url "localhost:5001/1204225829" -v
..
< HTTP/1.0 302 FOUND
< Content-Type: text/html; charset=utf-8
< Location: https://gooogle.com
...

Achitectural choices

  • Given time constraints, an in memory python dictionary object is used to store mapping of URLs to generated identifiers
  • Lookup and shorten endpoint can be provided with optional ?format=<json|xml> query parameter which them generates json or XML output. Json is default in cases when no format parameter is supplied or format != <json|xml>
  • Please refer to comments in main app.py file, it contains more insight into app's functionality

Build and deploy

The application is intended to run in a docker container. To build:

docker build --tag url-shortener . 

The application is then run exposing an example port 5001 as it's API endpoint:

docker run --publish 5001:5001 url-shortener

url-shortener's People

Contributors

zepellin 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.