URL Shortner
URL Shortner
- TEAM BEGINNERS
ABOUT THE
TOPIC
• A URL shortener is a tool or service that takes a long URL and creates a
shorter, more manageable version.
• Fuzzy URL also known as URL Shortener.
• These shortened URLs redirect users to the original, longer URL when clicked.
• URL shorteners work by assigning a unique identifier to each long URL
submitted to the service. When a user clicks on the shortened URL, the
service redirects the user's browser to the original, longer URL associated
with that identifier.
ADVANTAGES
DISADVANTAGES
ADVANTAGES OF USING URL
SHORTNER
• Convenience: Short URLs are easier to share, especially in contexts where character count is limited, such as social media
platforms like Twitter.
• Space Saving: Shortened URLs take up less space, which can be particularly beneficial in situations like email newsletters or
SMS messages.
• Improved Aesthetics: Long URLs can look cluttered and unattractive, especially when embedded in a text. Shortened URLs
tidy up the appearance.
• Tracking and Analytics: Many URL shortening services offer analytics, allowing users to track click-through rates,
geographic location of clicks, and other metrics, which can be valuable for marketing campaigns or understanding
audience behaviour.
• Customization: Some URL shorteners allow users to customize the shortened link with a branded or personalized domain,
which can enhance brand recognition and trust.
• Redirection: Shortened URLs can be redirected, which means if the destination URL changes, the shortened URL can still
direct users to the correct page without needing to change the shortened link.
• Security: Some URL shorteners offer security features such as link expiration, password protection, or even malware
detection to ensure the safety of users who click on the links.
DISADVANTAGES
• Loss of Control: When you shorten a URL using a URL shortener service, you're relying on that
service to maintain the redirection. If the service goes down or shuts down, all the shortened
links may become inaccessible.
• Security Risks: Shortened URLs can obscure the destination, making it easier for malicious actors
to disguise phishing or malware links. Users may be hesitant to click on shortened links from
unknown sources due to security concerns.
• Link Rot: If the original URL changes or becomes invalid, the shortened URL may lead to a dead
end, resulting in link rot. This can happen if a webpage is moved, deleted, or the domain expires.
• Trust Issues: Some users may be wary of clicking on shortened URLs, especially if they don't know
the source. This can lead to lower click-through rates and decreased effectiveness of marketing
campaigns or shared content.
WHAT ARE THE PREREQUISITES
FOR OUR PROJECT
The MODULES, OBJECTS AND CLASSES which are required in order to
understand the code are :
1. Flask
2. From flask – render_template, redirect, request
3. Random
4. String
5. App routing using GET & POST requests.
RANDOM MODULE
• The random module in Python provides functions for generating random
numbers. It's commonly used in various applications, including simulations,
games, cryptography, and statistical analysis.
• Some examples
• random.random(): Returns a random floating-point number in the range [0.0,
1.0).
• random.choice(seq): Returns a random element from a non-empty sequence.
STRING MODULE
• The string module in Python provides various constants and functions for working
with strings. Here's an overview of some of the key features of the string module:
• string.ascii_letters: A string containing ASCII uppercase and lowercase letters
('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ').
• string.ascii_lowercase: A string containing ASCII lowercase letters
('abcdefghijklmnopqrstuvwxyz').
• string.ascii_uppercase: A string containing ASCII uppercase letters
('ABCDEFGHIJKLMNOPQRSTUVWXYZ').
REDIRECT AND REQUEST FROM
FLASK
• In Flask, the redirect function is used to redirect the user to a different URL. This
function is particularly useful when you want to redirect users after they have
submitted a form, accessed a particular route, or for any other scenario where
you need to direct them to a different page.
• In Flask, the request object allows you to access incoming request data such as
form data, query parameters, files uploaded with the request, and more. It
encapsulates the HTTP request sent by the client and provides attributes and
methods to access its various components.
APP ROUTES USING "GET" &
"POST"
• In Flask, @app.route("/", methods=["GET", "POST"]) is a decorator used to define a route for the application. Let's break it
down:
• @app.route("/"): This part indicates that the decorated function (GET and/or POST method in this case) will be triggered
when the user accesses the root URL of the application ("/"). In Flask, routes are the URLs that the application responds to.
So, in this case, it means the function will be triggered when someone accesses the home page of the application.
• methods=["GET", "POST"]: This part specifies the HTTP methods that the route should respond to. In this case, it specifies
that the route should respond to both GET and POST requests.
• So, together, @app.route("/", methods=["GET", "POST"]) means that the decorated function will be triggered when
someone accesses the root URL of the application, and it will respond to both GET and POST requests to that URL.
• GET:
• GET requests are used to retrieve data from a server.
• The data is appended to the URL as a query string, which is limited in length (typically around 2000 characters).
• POST:
• POST requests are used to send data to a server for processing, such as submitting a form or creating a new resource.
• The data is sent in the request body of the HTTP request, which has no length limitation.
SOURCE CODE -- FUZZY URL
(PYTHON FILE)
SOURCE CODE -- FUZZY URL
(HTML FILE)
THANK YOU
THANKS!