This is a simple URL shortener built using the Python web framework Flask and an SQLite database.
-
Clone the repository:
git clone https://github.com/krishnagopal596/urlslicer.git cd urlslicer
-
Create a virtual environment:
python -m venv venv
-
Activate the virtual environment:
.\venv\Scripts\Activate
(You should see
(venv)
at the start of your prompt.) -
Install required packages:
pip install -r requirements.txt
-
Initialize the database:
python urlslicer\init_db.py
-
Create a
.env
file in theurlslicer
folder (whereapp.py
is located):FLASK_APP=app FLASK_ENV=development
-
Run the Flask application from your project root folder:
python -m flask run
-
Open http://localhost:5000 in your browser to use the app.
Notes:
- All commands after step 3 must be executed while the virtual environment is activated.
- If you deploy to production, change
FLASK_ENV=production
in your.env
file. - If you encounter issues with
flask run
, always trypython -m flask run
.
- Enter a long URL in the input box and press Submit.
- The shortened URL will appear below. Press Copy URL to copy it and paste it in another browser window.
Enjoy using URL Slicer!