Skip to content

Skullheader1/LIALS

Repository files navigation

Link Shortener

A link shortener web application, featuring user authentication, link management, and detailed statistics. The app supports both regular users and admins, allowing for efficient link creation, monitoring, and user management.

Setup

1. Install dependencies

python3 -m pip install -r dependencies.txt

2. Configure database

Edit config.ini:

[database]
database_uri = sqlite:///database.db

or set the DATABASE_URI environment variable.

For MySQL/PostgreSQL, use the corresponding SQLAlchemy URI.

3. Configure host and port

Edit config.ini:

[server]
host = 0.0.0.0
port = 5050

or set the HOST and PORT environment variables.

4. Run

python3 main.py

A default root user is created on first start with the password root. You will be prompted to change it on first login.

Features

Link Management

  • Create short links with optional expiry and click limits
  • Search links by short code, target URL, or owner (admin)
  • Activate/Deactivate links without deleting them
  • Delete links with confirmation dialog

Link Expiry & Max Clicks

  • Set a time-to-live (in days) when creating a link — expired links return HTTP 410
  • Set a max click limit — links stop redirecting once the limit is reached
  • Status badges show the current state: Active, Inactive, Expired, Max clicks

Link Statistics

  • Detailed stats page per link with:
    • Click count and usage percentage
    • Creation date, expiry date, and remaining time
    • Link owner
    • Quick actions (activate/deactivate, delete)

User Management (Admin)

  • Manage users
  • Search users by username or ID
  • Toggle admin rights and active status
  • Reset user passwords

Tech Stack

  • Backend: Python, Flask, SQLAlchemy
  • Frontend: Jinja2, Bootstrap 5 (dark theme), Bootstrap Icons
  • Auth: Flask-Login with Argon2 password hashing

Routes

Route Method Auth Description
/ GET - Redirect to dashboard or login
/login GET/POST - Login page
/register GET/POST - Registration
/s/<code> GET - Redirect short link
/dashboard GET/POST User Create new links
/my_links GET/POST User View own links with search & pagination
/link_stats/<id> GET User Link statistics page
/toggle_link_active/<id> POST User Activate/deactivate link
/delete_link/<id> POST User Delete own link
/all_links GET/POST Admin View all links with search
/manage_users GET/POST Admin User management with search
/toggle_user_active/<uuid>/<active> POST Admin Enable/disable user
/toggle_admin/<uuid>/<admin> POST Admin Grant/revoke admin
/reset_user_password/<uuid> POST Admin Reset user password

Usage of AI

  • Github Copilot: Used in PyCharm for small code suggestions
  • Claude: Used for polishing the frontend templates

Note: Every code snippet generated by AI was reviewed and modified if needed.

About

A link shortener web application, featuring user authentication, link management, and detailed statistics.

Topics

Resources

License

Stars

Watchers

Forks

Contributors