Package shortner
URL-Shortner 🔗
URL-Shortner - Simple URL shortener
Wondering why the Shortner is misspelled? Thats because this project is all about making it short, simple and easy to share. URL-Shortner aims to be the easiest ad-free url shortener that can be used to quickly generate sharable short urls.
-
Ever typed out a long url on your phone only to see that you missed a '/' or misspelled a word?
-
Have you shared multiple URLs with others because you sent an incorrect URL earlier?
-
Had to update the same document every year but with updated URL, wondering if there was a way to keep the URL the same and just redirect to new one every year?
If you answered yes to any of the above questions, then this is going to bring a smile to your face! The URL-Shortner is a simple tool that you can utilize to create short versions of that long urls and share it with others. Additionally, its just a few clicks to update an existing URL if you made a mistake or the URL has changes over time. If you don't need it anymore, simply go ahead and delete that.
URL-Shortner has APIs developed using python and front-end web application developed using angular.
How to use?
Generate
Go to yoururl.tech/url-shortner
Enter the long version of the URL you want to generate a short version and click Get short URL. You should see a popup mentioning the short version of URL and an access code. This code can be utilized to update or delete an existing URL.
Save the access code, since you won't be able to access it later.
Update
Click on Update Existing URL button. This will take you to the update url page.
Enter the following details:
-
Short URL stub: This is the last part of the short version of url. Eg: For the URL http://sef22group5.pythonanywhere.com/stub/oe7p1SKtPS,
oe7p1SKtPS
is the stub. -
Access Code: This is the code that was provided to you at the time of creating new short URL.
-
Updated long URL:: Enter the updated URL for the existing short version of URL.
Click on Update URL and if all fields are correct and validated, the URL should be updated.
Delete
If you no longer need a URL, click on Delete Existing URL button on the home page.
Enter the access code that was provided to you at the time of creating new short URL. Click on Delete URL, and if the access code is correct, it will successfully delete the URL.
We love our contributors ❤️❤️
Make a pull request to help contribute.
URL Shortner APIs
This folder houses the Django API used for the URL Shortner.
The Django project is named url_shortner_server
while the app within is called shortner
.
Development
To add new features or fix a bug in the API, you can perform the following steps:
- Clone the repository.
- Install Python 3 from here for your choice of operating system.
- Run
pip install -r requirements.txt
. - Run
python manage.py runserver
to start the server. - To make sure the API is running, visit
http://localhost:8000/admin
to see the default Django admin interface.
Deployment
The API has been deployed using PythonAnywhere. Instructions for deployment can be found here.
Troubleshooting
Some common HTTP status codes that can be seen in the logs provided by the Django server:
Status Code | Description | Resolution |
---|---|---|
400 | Bad Request | Check the HTTP request to be valid for the URL. |
404 | Not Found | The URL being visited has no view attached to it, check the URL. |
405 | Method Not Allowed | The HTTP request is using a different method than the one expected by the URL, check to make sure the correct method is used. |
500 | Internal Server Error | This error usually means there was an exception that was not handled. Check the logs to find the source of the error. |
Files
File | Description |
---|---|
manage.py |
This file is used for running Django project commands. Full list can be seen here |
db.sqlite3 |
This is the database of the project, ideally should not be committed to the repository (this repository does not contain this file). If the file is missing, the project generates it. |
requirements.txt |
Contains the requirements for the project. |
Export
Data for the project can be exported in JSON format using the following command:
python manage.py dumpdata > data.json
Expand source code
"""
.. include:: ../../README.md
.. include:: ../README.md
"""
import os
if not os.environ.get("DJANGO_SETTINGS_MODULE"):
import django
os.environ["DJANGO_SETTINGS_MODULE"] = "url_shortner_server.settings"
django.setup()
Sub-modules
shortner.admin
shortner.apps
shortner.constants
-
Constants module stores the constants used in the application
shortner.delete_view
-
delete_view module defines the view that user wants to delete
shortner.migrations
shortner.models
-
Models module deals with models representing entities in the application
shortner.new_view
-
new_view module defines the NewView view
shortner.stub_view
-
stub_view module has views for stub
shortner.tests
shortner.update_view
-
update_view module defines the UpdateView view
shortner.views
-
Views module stores all the views of the application