4 Line python-based URL shortener

I go by theroyakash on the internet. I am a computer scientist, with research in high performance algorithms, data structures, distributed systems, and beyond. See my work searching google for theroyakash.
Search for a command to run...

I go by theroyakash on the internet. I am a computer scientist, with research in high performance algorithms, data structures, distributed systems, and beyond. See my work searching google for theroyakash.
No comments yet. Be the first to comment.
Graph implementation and usage in C++

Clearing pre order, in order and post order traversal confusion under 2 minutes

Setup audio version of your articles for free.
![Set-up an audio version of your blog articles [Works Automatically]](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1612940767582%2F0abS3UT_8.png&w=3840&q=75)
Build and run algorithms on Priority Queues (as binary heaps) with just a few lines of code with AKDSFramework.

Introducing an efficient Big O analyzer, a premium state-of-the-art AKDSFramework feature to analyze Big O for any function without any human intervention. As you already know calculating big O is a big part of what we do to approximate the running t...

Let's build an URL shortener with just 4 lines of code. I'll keep it as simple as possible.
I was building a discord BOT that has the feature of sending top news article in a given hour, but the URLs were too long so it was looking bad in a discord chat. So I thought of making an shortener service based on tiny-url to beautify those long a** URLs.
contextlib for utilities for with-statement contexts,urllib module which are built-in. So nothing needed to be installed.import contextlib
from urllib.parse import urlencode
from urllib.request import urlopen
def tinyURLOf(url):
encoded_url = urlencode({'url': url})
request_url = 'http://tinyurl.com/api-create.php?' + str(encoded_url)
with contextlib.closing(urlopen(request_url)) as response:
return response.read().decode('utf-8 ')
So now run the function tinyURLOf(url='YOUR_URL_HERE') to get the result back.