This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
data = '{"sender":"218311","message":"english"}' | |
response = requests.post('http://127.0.0.1/webhooks/rest/webhook', data=data) | |
# print(response.text) | |
# response.text | |
import json | |
r = response.json() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import aiohttp | |
async def call_url(session): | |
url = "http://127.0.0.1:5005/webhooks/rest/webhook" | |
data = '{"sender":"218311","message":"english"}' | |
response = await session.post(url=url, data=data) | |
return response | |
# async def call_with_aiohttp(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import aiohttp | |
url = "http://127.0.0.1:5005/webhooks/rest/webhook" | |
data = '{"sender":"218311","message":"english"}' | |
async def aiohttp_session(): | |
async with aiohttp.ClientSession() as session: | |
async with session.post(url, data=data) as r: | |
return await r.json() if r.status ==200 else await r.text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools | |
def memoize(obj): | |
cache = {} | |
@functools.wraps(obj) | |
def memoizer(*args, **kwargs): | |
if args not in cache: | |
cache[args] = obj(*args, **kwargs) | |
return cache[args] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# AES 256 encryption/decryption using pycrypto library | |
""" | |
used Python version: | |
-------------------- | |
Python3.8 | |
requirements: | |
------------ | |
pip3 install -U PyCryptodome |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#------------------- Requirements ------------------------ | |
pip install bcrypt | |
#------------------- Hashing Password --------------------- | |
import bcrypt | |
passwd = b'xyz123' | |
salt = bcrypt.gensalt() |