Git Product home page Git Product logo

url_shortener's Introduction

How to install:

  1. install docker and docker-compose (please download version 4.8.2).
  2. inside cloned repo, build the container with docker-compose build
  3. and run the project docker-compose up
  4. (only after build) apply migrations docker-compose exec web python manage.py migrate

Example usage using curl:

# start the service~ docker-compose up

Example requests

# create alias~ curl -d "target=https://szkolawchmurze.org/edukacja-domowa/liceum" localhost:8000/generate
{"target":"https://szkolawchmurze.org/edukacja-domowa/liceum","alias":"http://localhost:8000/68D63D"}

# get target of just created alias~ curl http://localhost:8000/68D63D
{"target":"https://szkolawchmurze.org/edukacja-domowa/liceum"}%

# try to generate alias to invalid url~ curl -d "target=notfound://szkolawchmurze.org/edukacja-domowa" localhost:8000/generate
{"target":["Enter a valid URL."]}%

# generate second proper alias~ curl -d "target=https://szkolawchmurze.org/edukacja-domowa" localhost:8000/generate
{"target":"https://szkolawchmurze.org/edukacja-domowa","alias":"http://localhost:8000/BFC936"}%

# try to generate alias that will point to already existing target~ curl -d "target=https://szkolawchmurze.org/edukacja-domowa/liceum" localhost:8000/generate
{"target":"https://szkolawchmurze.org/edukacja-domowa/liceum","alias":"http://localhost:8000/68D63D"}

Aliases can also be accessed in admin view at localhost:8000/admin/alias/alias/


Running tests:

~ ./run_tests.sh 
***************
Clean Tests
***************
Stopping url_shortener_2_web_1 ... done
Stopping url_shortener_2_db_1  ... done
Removing url_shortener_2_web_1                ... done
Removing url_shortener_2_web_run_db82f994bd9d ... done
Removing url_shortener_2_db_1                 ... done
Removing network url_shortener_2_default
***************
Start new test session
***************
Creating network "url_shortener_2_default" with the default driver
Creating url_shortener_2_db_1 ... done
Creating url_shortener_2_web_run ... done
Found 12 test(s).
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
............
----------------------------------------------------------------------
Ran 12 tests in 0.072s

OK
Destroying test database for alias 'default'...
***************
Stop containers after tests
***************
Stopping url_shortener_2_db_1 ... done

url_shortener's People

Contributors

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