https://github.com/mhmdkanj/slash-idk
URL shortener local web app
https://github.com/mhmdkanj/slash-idk
django python3 url url-shortener webapp
Last synced: 6 months ago
JSON representation
URL shortener local web app
- Host: GitHub
- URL: https://github.com/mhmdkanj/slash-idk
- Owner: mhmdkanj
- License: mit
- Created: 2022-02-27T23:08:09.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-03-07T22:53:47.000Z (over 4 years ago)
- Last Synced: 2025-02-02T08:43:21.128Z (over 1 year ago)
- Topics: django, python3, url, url-shortener, webapp
- Language: Python
- Homepage:
- Size: 37.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# slash/idk
`slash/idk` *(Slash, I don't know)* is a [Django](https://www.djangoproject.com/)-based web app that lets you run a simple local web server, where you can shorten long URLs with the name of your choice.
By providing the desired name as a subdirectory to the server's domain name, the app redirects you to the original page mapped to this name.
## Requirements
To run the web app, you primarily need the following installed on your system:
- [Python 3.7+](https://www.python.org/)
## Install
To install the web app, clone the repository in the directory of your choice and enter the project's root directory:
```sh
git clone https://github.com/mhmdkanj/slash-idk.git
cd slash-idk
```
It is highly recommended to deal with the app within a virtual environment.
For more info regarding virtual environments, please refer to the [Python docs](https://docs.python.org/3/tutorial/venv.html).
To create one, execute the following:
```sh
python3 -m venv ./venv
source ./venv/bin/activate # for Unix/MacOS systems
# OR
venv\Scripts\activate.bat # for Windows systems
```
Now, you can safely install the dependencies of the web app using [pip](https://pypi.org/project/pip/):
```sh
pip install -r requirements.txt
```
Just for the first time, it is required to set up the database used by the web app (or at least make sure it's okay) by just running the following Django commands:
```sh
python src/manage.py makemigrations
python src/manage.py migrate
```
## Usage
To run the server, use the following Django command:
```sh
python src/manage.py runserver
```
Most probably, the web server will use port `8000` (otherwise, check the output of the previous command).
If that's the case, then you can open the app by inputting the following URL in your web browser: [http://localhost:8000/](http://localhost:8000/)
### Shortening a URL
To add a mapping:
1. Paste your URL in the first field
2. Enter a short name in the second field
3. Just click `Save`!
For instance, if typing out `http://google.com` tires you, and you would rather use something short like `ggl`, you can input this info as such and then click save:

The next time you want to visit this site, you can then enter in your browser:
`http://localhost:8000/ggl`, which redirects you to `http://google.com`.
You can also click on `"Suggest Name"` to suggest a randomly generated shortened name for the URL.
### Displaying Saved URLs
Click on `"My URLs"` on the navigation bar to list all saved shortened URLs.
You can also choose to delete any of them by clicking on the button next to the desired entry.

### Quitting the Server
To quit the server, press `Ctrl`+`C` within the terminal the server was launched from.