GithubHelp home page GithubHelp logo

url-shortener's Introduction

URL Shortener with FastAPI

CI

https://github.com/tiangolo/fastapi

$ docker version
Client:
Version:           20.10.12
API version:       1.41
Go version:        go1.17.3
Git commit:        20.10.12-0ubuntu4
Built:             Mon Mar  7 17:10:06 2022
OS/Arch:           linux/amd64
Context:           default
Experimental:      true

Server:
Engine:
Version:          20.10.12
API version:      1.41 (minimum version 1.12)
Go version:       go1.17.3
Git commit:       20.10.12-0ubuntu4
Built:            Mon Mar  7 15:57:50 2022
OS/Arch:          linux/amd64
Experimental:     false
containerd:
Version:          1.5.9-0ubuntu3.1
GitCommit:
runc:
Version:          1.1.0-0ubuntu1.1
GitCommit:
docker-init:
Version:          0.19.0
GitCommit:

$ docker compose version
Docker Compose version v2.12.2
$ 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 -f
$ docker compose exec db psql --username=dev --dbname=dev # Check database schemas
$ docker compose exec api pytest # Run test

Using curl and jq:

$ 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

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

url-shortener's Issues

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.