Giter VIP home page Giter VIP logo

guptag911 / smolink-url_shortener Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ksh168/smolink-url_shortener

0.0 1.0 0.0 1.59 MB

This is a simple URL shortener in Flask. Shortens URL upto length 512 characters to 6 characters. Made using Flask-SQLAlchemy. This URL shortener will be able to redirect links and keep stats on the number of times each link was visited. Also has HTTP Basic Authentication to view stats. All this data will be stored in a sqlite3 database.

Home Page: https://www.smolink.tech

Python 40.08% HTML 51.10% CSS 3.23% JavaScript 5.58%

smolink-url_shortener's Introduction

URL_Shortener - smolink

Access the service here or here

This project was born out of my curiosity for how URL Shorteners work.

This is a simple URL shortener in Flask.

Shortens URL upto length 512 characters to 6 characters.

Made using Flask-SQLAlchemy. This URL shortener will be able to redirect links and keep stats on the number of times each link was visited.

Also has HTTP Basic Authentication to view stats.

All this data will be stored in a sqlite3 database

Goals of this project

✅ Users can create personalized URLs

✅ Check user input to make sure it's URL

✅ Support for ftp[s]

✅ Ability to view stats for individual links by adding "/stats" to URL

✅ Public HTTPS website deployed

  • User can create a account and then generate and manage all the links and their stats from there

  • Security against cyber attacks

(more will be added along the way)

  • "link" Table in the Database

User Interface

  • UI walk-through

  • Index page

  • Short URL generated

  • Custom Short URL generated

  • Incase custom selected URL already exists

  • Individual link Statistics

  • Global Statistics (Needs admin HTTP Authentication)

Steps:

Always recommended to create a virtual environment

Method1: (Recommended)

  • pip3 install python3-venv

  • Create a virtual environment called venv

    python3 -m venv ./venv

  • Activate venv

    source venv/bin/activate

  • Install dependencies

    pip install -r requirements.txt

Method2:

  • Create virtual environment and install flask

    pipenv install flask

  • To start shell and enter the venv

    pipenv shell

  • Dependencies:(this step might not be needed)

    pipenv install python-dotenv

    pipenv install sql-alchemy

  • To run the app

    start shell if not started pipenv shell

    flask run

Now to create the database

  1. Start python in terminal

    python

  2. 	from url_shortener import create_app
  3. 	from url_shortener.extensions import db
  4. 	from url_shortener.models import Link
  5. To create tables and database

    	db.create_all(app = create_app())
  6. To exit python console

    	exit()
  • To view database, write in terminal

    sqlite3 url_shortener/db.sqlite3

  • To see the table names in database

     	.tables
  • To query the database

     SELECT * FROM link;
  • To delete table contents but not table

     DELETE FROM link;
  • To exit sqlite3

     	.exit

Contributing

  • First off, thank you for considering contributing.

  • There are many ways to contribute, from improving the documentation, submitting bug reports and feature requests or writing code which can be incorporated into project itself.

  • Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

  • Please make sure to add you issue number while submitting your pull request (PR).

  • You can also edit the readme and make it more user friendly to help out new contributors.

Link to resources for first timers:

Submitting a pull request

  • The smaller the proposed change, the better. If you’d like to propose two unrelated changes, submit two pull requests.

  • The more information, the better. Make judicious use of the pull request body. Describe what changes were made, why you made them, and what impact they will have for users.

  • If this is your first pull request, it may help to understand GitHub Flow.

  • Including screenshots/video of final interface/changes in your pull request is a must.

Community

  • You can chat with the community here or here.

Acknowledgements

This project was made using GitHub Codespaces Beta. Thanks to them for providing me early access to their such beautiful and useful feature.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.