Giter VIP home page Giter VIP logo

urlshortener's Introduction

URL Shortener

Summary

When a user visits the site, she is presented with a form. She can enter the URL she would like to shorten, and the system will automatically generate a short URL for her to copy.

The long URL is stored as the base_url of a Link instance. When the form is submitted, the LinkManager runs find_or_create, searching for a Link that already exists with the entered base_url. If one exists, it will be returned and the user will see the short_url, which is a concatenation of the domain (settings.DOMAIN) and the randomly-generated short_string. If one does not exist, a new one will be created with this base_url and a short_string will be randomly generated in generate_short_string.

When a user navigates to a short_url, the redirect view will search for a Link that exists with a matching short_string and redirect to its base_url if it exists, rendering a 404 if it does not.

An admin is able to log in and see the entire list of Links that have been created.

Running locally

This app was built using Django 1.9.8 and Python 3.5.2. Mac OSX provides support for Python 2 and 3, naming all Python 3 commands as python3 and Python 2 as python. For the purposes of this documentation, I will say python in the places where I used python3.
Packages Needed: sure, faker
  • Clone the repo and cd into the directory.
  • I've checked the sqlite file into VC, so you shouldn't need to run migrations, but if you do, run python manage.py migrate.
  • You can create an admin user with python manage.py createsuperuser.
  • I have the DOMAIN constant in settings.py set to "http://localhost:8000". To run the local server with this configuration, run python manage.py runserver localhost:8000. In a browser, go to localhost:8000 to use the site.
  • You can also log in as the admin user you created at /admin to see the list of Links in the database.
  • You can run tests with python manage.py test urlshortener.

urlshortener's People

Contributors

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