Giter VIP home page Giter VIP logo

link-shortening-api's Introduction

Documentation

This project is a test api in python that creates shortened url.


Installation

Prerequisites

In order to run this code you need to have these installed on your machine:

  • Python 3.9, Python3
  • Pip3
  • Uvicorn or similar

You can check these by typing this code into your terminal

python3 --version 
pip3 --version
uvicorn --version

Clone Project

Navigate into the directory of your choice and clone the repository. Then run following commands:

git clone [email protected]:wedalb/link-shortening-api.git

Installing the requirements

Install the requirements text:

python -m pip install -r requirements.txt

Usage

Start Uvicorn

Run uvicorn to be able to try out the endpoints and make requests

cd default-python-xgjeuv/src

uvicorn api:app --reload

Then in your browser, postman or similar you can try out the endpoints.

For trying out the endpoints I recommend the browser or terminal

Browser:

Open one of the following addresses in your browser. This will redirect you to a documentation website that tells you everything about the endpoints. Also, you can press the "Try it out" button and try the api

http://127.0.0.1:8000/docs 

browser image

http://127.0.0.1:8000/redoc

browser image

Terminal

You can open a second window for the terminal and try the following code to encode an url

curl http://127.0.0.1:8000/encode/htttp://example-url.org

This will return:

  {
    "encoded_url": "http://short.est/2KRT7a"
  }

After that you can try

curl http://127.0.0.1:8000/decode/http://short.est/2KRT7a

And it shall return

  {
    "decoded_url": "example-url.org"
  }

Running tests

To run test simply stay in the directory and run

pytest

Libraries

  • FastApi
  • Pythons random function
  • pydantic
  • pytests

link-shortening-api's People

Contributors

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