Code Monkey home page Code Monkey logo

url-shortener's Introduction

URL Shortener with FastAPI

https://github.com/tiangolo/fastapi

$ git clone https://github.com/vancanhuit/url-shortener.git
$ cd url-shortener
$ docker-compose up -d --build
$ docker-compose exec api alembic upgrade head # Run for the first time to initialize database schemas
$ docker-compose logs
$ docker-compose exec db psql --username=dev --dbname=dev # Check database schemas

Using curl:

$ curl -X POST -d '{"url": "https://google.com"}' -H "Content-Type: application/json" http://localhost:8000/api/shorten | jq .
{
  "short_link": "Nw4IY0Y"
}

Using httpie:

$ http POST localhost:8000/api/shorten url=https://freecodecamp.org

HTTP/1.1 200 OK
content-length: 24
content-type: application/json
date: Wed, 15 Jul 2020 13:56:37 GMT
server: uvicorn

{
    "short_link": "pk9nq5_"
}

Point your browser to http://localhost:8000/Nw4IY0Y or http://localhost:8000/pk9nq5_ (the links will be varied because they depend on timestamp).

url-shortener's People

Contributors

bashar avatar dependabot[bot] avatar vancanhuit 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.