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
class SampleView(APIView): | |
def get(self, request): | |
token = request.META.get('HTTP_AUTHORIZATION') | |
access_token = token.split()[-1] | |
print(access_token) | |
return Response({'token': access_token}) |
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 | |
import pkg_resources | |
from bs4 import BeautifulSoup | |
from pkg_resources import parse_version | |
from subprocess import call | |
base_url = "https://pypi.org/project/" | |
for pkg in pkg_resources.working_set: | |
original_version = pkg.version |
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 re | |
import matplotlib.pyplot as plt | |
with open('chat.txt', 'r') as f: | |
content = f.readlines() | |
all_dates = [] | |
for line in content: | |
dates = re.findall(r'[0-9]+/[0-9]+/[0-9]+', line) | |
if dates: |
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
from captcha.image import ImageCaptcha | |
import string | |
import random | |
text = ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for _ in range(10)) | |
image = ImageCaptcha() | |
data = image.generate(text) | |
image.write(text, 'captcha.png') |
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
{ | |
"search_result": [ | |
{ | |
"index": 0, | |
"id": "PLhe6bv3puIj1r64ot4k76YkGhJpFdhCxU", | |
"link": "https://www.youtube.com/playlist?list=PLhe6bv3puIj1r64ot4k76YkGhJpFdhCxU", | |
"title": "All Coldplay Songs" | |
}, | |
{ | |
"index": 1, |
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
{ | |
"search_result": [ | |
{ | |
"index": 0, | |
"id": "PLhe6bv3puIj1r64ot4k76YkGhJpFdhCxU", | |
"link": "https://www.youtube.com/playlist?list=PLhe6bv3puIj1r64ot4k76YkGhJpFdhCxU", | |
"title": "All Coldplay Songs" | |
}, | |
{ | |
"index": 1, |
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
{ | |
"search_result": [ | |
{ | |
"index": 0, | |
"id": "kJQP7kiw5Fk", | |
"link": "https://www.youtube.com/watch?v=kJQP7kiw5Fk", | |
"title": "Luis Fonsi - Despacito ft. Daddy Yankee", | |
"channel": "Luis Fonsi", | |
"duration": "4:42", | |
"views": 6874955394, |
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
from rest_framework.response import Response | |
from rest_framework.views import APIView | |
class AuthTest(APIView): | |
def get(self, request): | |
try: | |
username = "User@123" | |
password = "htd61m12;!@" | |
auth_header = request.META.get('HTTP_AUTHORIZATION', '') |
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 pkg_resources | |
from subprocess import call | |
packages = [] | |
for pkg in pkg_resources.working_set: | |
packages.append(pkg.project_name) | |
call("pip install --upgrade " + ''.join(packages), shell=True) |
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
Student.objects.filter(is_active=False).update(is_active=True) |