Embrace simplicity and efficiency β say NO to external Python packages for smaller projects! π₯
This repository contains various Python utility functions for common tasks such as encryption, decryption, OTP generation, HTTP requests, and list shuffling.
Generates a numeric OTP (One-Time Password) of a specified length.
-
Parameters:
length
(int): The length of the OTP to generate. Default is 4.
-
Returns:
str
: The generated OTP.
Generates a mixed alphanumeric OTP (One-Time Password) of a specified length.
-
Parameters:
length
(int): The length of the OTP to generate. Default is 5.
-
Returns:
str
: The generated OTP.
Makes a GET request to the specified URL and prints the response.
- Parameters:
url
(str): The URL to which the GET request is made.
Makes a POST request to the specified URL with the given data and prints the response.
- Parameters:
url
(str): The URL to which the POST request is made.data
(dict): The data to be sent in the POST request.
Makes a PUT request to the specified URL with the given data and prints the response.
- Parameters:
url
(str): The URL to which the POST request is made.data
(dict): The data to be sent in the POST request.
Makes a PATCH request to the specified URL with the given data and prints the response.
- Parameters:
url
(str): The URL to which the POST request is made.data
(dict): The data to be sent in the POST request.
Makes a DELETE request to the specified URL with the given data and prints the response.
- Parameters:
url
(str): The URL to which the POST request is made.
Shuffles a list using a pseudo-random number generator based on the current time.
-
Parameters:
arr
(list): The list to be shuffled.
-
Returns:
list
: A new list with the elements shuffled.
A basic HTTP server example that serves a simple "Hello, World!" HTML page.
- Usage:
- Run the server using
python -m web_server.server
. - Open a web browser and visit
http://localhost:8000
to see the served page.
- Run the server using
from otp_generator.number import number_otp
number_otp = number_otp(length=5)
print(f"Numeric OTP: {number_otp}")
from otp_generator.mixed import mixed_otp
mixed_otp = mixed_otp(length=5)
print(f"Mixed OTP: {mixed_otp}")
from request.get import get_request
url = 'https://servebin.dev/json'
get_request(url)
from request.post import post_request
post_url = 'https://servebin.dev/post'
post_data = {'key': 'value'}
post_request(post_url, post_data)
from request.delete import delete_request
delete_url = 'https://servebin.dev/delete'
delete_request(delete_url)
from request.put import put_request
put_url = 'https://servebin.dev/put'
put_data = {'key': 'new_value'}
put_request(put_url, put_data)
from request.patch import patch_request
patch_url = 'https://servebin.dev/patch'
patch_data = {'key': 'modified_value'}
patch_request(patch_url, patch_data)
from core_random.shuffle import shuffle_list
my_list = [1, 2, 3, 4, 5]
shuffled = shuffle_list(my_list)
print(f"Original List: {my_list}")
print(f"Shuffled List: {shuffled}")
This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.