Welcome to the URL Slice Application! This project is a fast, reliable, and easy-to-use service for creating shortened URLs. It is built using Python, FastAPI, and comes with an interactive API documentation powered by Swagger.
- Create Short URLs: Quickly generate a shortened URL from a long URL.
- Redirect: Automatically redirect users to the original URL when the short link is accessed.
- Custom Aliases: Optionally create custom short links for easy memorization.
- Interactive API Documentation: Built-in Swagger UI for testing and exploring the API.
- Lightweight and Scalable: Built with FastAPI, optimized for performance and scalability.
- Python: Programming language used for development.
- FastAPI: Framework for building the API.
- SQLite: Default database for storing URL mappings (easily replaceable).
- Uvicorn: ASGI server for running the application.
- Python 3.9 or later
- pip (Python package installer)
-
Clone the repository:
git clone https://github.com/jawnchuks/url-slice.git cd url-shortener
-
Create a virtual environment:
python3 -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install dependencies:
pip install -r requirements.txt
-
Run the application:
uvicorn app.main:app --reload
-
Access the application:
- API Documentation: http://127.0.0.1:8000/docs
- Redoc Documentation: http://127.0.0.1:8000/redoc
POST /shorten
- Request Body:
{ "long_url": "https://example.com", "custom_alias": "example" # Optional }
- Response:
{ "short_url": "http://127.0.0.1:8000/example" }
GET /{short_url}
- Access a short URL, and it will redirect to the original URL.
GET /urls
- Response:
[ { "long_url": "https://example.com", "short_url": "http://127.0.0.1:8000/example", "created_at": "2024-01-01T00:00:00" } ]
url-shortener/
├── app/
│ ├── main.py # Application entry point
│ ├── models.py # Database models
│ ├── routes.py # API endpoints
│ ├── schemas.py # Pydantic schemas
│ ├── database.py # Database connection setup
├── tests/ # Unit and integration tests
├── requirements.txt # Project dependencies
└── README.md # Project documentation
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Submit a pull request with a detailed explanation.
This project is licensed under the MIT License. See the LICENSE file for more details.
For any inquiries or issues, please contact:
- GitHub: jawnchuks
- Email: jawnchuks@gmail.com