A simple URL shortener built using Python 3 and Flask. This app allows users to shorten long URLs and redirect to them using short URLs.
- Shorten a long URL into a short and unique URL.
- Redirect from a short URL to the original long URL.
- Flask-based web application.
Ensure that you have the following installed on your system:
- Python 3.x
- pip3 (Python package manager)
-
Clone this repository:
git clone https://github.com/your-username/url-shortener.git cd url-shortener
-
Create a virtual environment:
python3 -m venv venv
-
Activate the virtual environment:
- On Windows:
.\venv\Scripts\activate
- On macOS/Linux:
source venv/bin/activate
- On Windows:
-
Install the required dependencies:
pip3 install -r requirements.txt
-
Run the Flask application:
python3 app.py
-
Open your web browser and go to
http://127.0.0.1:5000/
to use the URL shortener.
- Visit the homepage at
http://127.0.0.1:5000/
. - Enter a long URL in the input field.
- Click on the "Shorten URL" button to get a shortened version of the URL.
- Use the generated short URL to redirect to the original long URL.
- User enters a long URL.
- The backend generates a unique short URL (hash/ID) for the provided long URL.
- The short URL is saved and returned to the user.
- When a user visits the short URL, the backend looks up the original long URL and redirects the user.
- Python 3.x
- Flask
- HTML, CSS for frontend
Feel free to fork this repository and submit a pull request if you'd like to contribute improvements!
This project is licensed under the MIT License - see the LICENSE file for details.