Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions Web Socket.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# Program to print a data & it's Metadata of online uploaded file using "socket".
import socket
skt_c = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
skt_c.connect(("data.pr4e.org", 80))
link = "GET http://data.pr4e.org/intro-short.txt HTTP/1.0\r\n\r\n".encode()
skt_c.send(link)
from colorama import Fore # this module for Color the font

# handling the exceptions
try:
skt_c = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
skt_c.connect(("data.pr4e.org", 80))
link = "GET http://data.pr4e.org/intro-short.txt HTTP/1.0\r\n\r\n".encode()
skt_c.send(link)
except(Exception) as e:
# this code runes on error in any connection
print(Fore.RED, e, Fore.RESET)

while True:
data = skt_c.recv(512)
Expand Down
19 changes: 13 additions & 6 deletions url_shortner.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
# Importing the required libraries.
import pyshorteners
from colorama import Fore # this module for font color

# Taking input from the user.
url = input("Enter URL: ")

# Creating an instance of the pyshorteners library.
shortener = pyshorteners.Shortener()
# exception handling
try:
# Creating an instance of the pyshorteners library.
shortener = pyshorteners.Shortener()

# Shortening the URL using TinyURL.
shortened_URL = shortener.tinyurl.short(url)
# Shortening the URL using TinyURL.
shortened_URL = shortener.tinyurl.short(url)

# Displaying the shortened URL.
print(f"Shortened URL: {shortened_URL}")
except(Exception) as e:
# this code runes on any error is generated by user
print(Fore.RED, "Enter Valid URL format", Fore.RESET)

# Displaying the shortened URL.
print(f"Shortened URL: {shortened_URL}")
24 changes: 22 additions & 2 deletions write_excel_file.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
import xlwt
import openpyxl
import xlwt # type: ignore
import openpyxl # type: ignore

# Workbook is created
xlwt_wb = xlwt.Workbook()

"""
we can also use of json object format for this file or code,
for the index we can use (for loop) and for data use json object.
example of json object:
{
"data":[
"ISBT DEHRADUN".
"SHASTRADHARA",
"CLEMEN TOWN",
"RAJPUR ROAD",
"CLOCK TOWER",
"ISBT DEHRADUN",
"SHASTRADHARA",
"CLEMEN TOWN",
"RAJPUR ROAD",
"CLOCK TOWER"
]
}
"""

# add_sheet is used to create sheet.
sheet1 = xlwt_wb.add_sheet("Sheet 1")

Expand Down
Loading