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 typing import * | |
import time | |
from django.core.cache import cache | |
TICKET_AMOUNT = 10 | |
TICK_SIZE = 0.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
import requests | |
from bs4 import BeautifulSoup as bs | |
from apps.proxy.models import Proxy | |
PROXY_URL = "https://www.sslproxies.org/" | |
TEST_URL = "https://www.google.com/" | |
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 collections import OrderedDict | |
from rest_framework.pagination import PageNumberPagination as BasePageNumberPagination | |
from rest_framework.response import Response | |
__all__ = ( | |
'PageNumberPagination', | |
'paginator_generate', | |
) |
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 typing import Dict, Type | |
from rest_framework.generics import ListAPIView | |
from rest_framework.response import Response | |
from ..paginator import PageNumberPagination | |
from .response_format import RestGetResponseMixin | |
__all__ = ('ListAPIViewPagination', ) |
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 typing import Dict, Any | |
from django.http.response import JsonResponse | |
from rest_framework.response import Response | |
BASE_RESPONSE_MESSAGE = { | |
'code': 200, | |
'meta': {}, | |
'data': {} |
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
# PROXY MODEL | |
class Proxy(models.Model): | |
host = models.CharField( | |
verbose_name='Host', | |
max_length=255 | |
) | |
is_valid = models.BooleanField( | |
verbose_name='Is valid', | |
default=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
# HANDLER | |
from django.utils.translation import ugettext_lazy as _ | |
from rest_framework.exceptions import ErrorDetail | |
from rest_framework.views import exception_handler | |
non_field_errors = 'non_field_errors' | |
def set_custome_errors(errors): |
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
# run.py file | |
from app.app import init | |
if __name__ == "__main__": | |
init() | |
# app/app.py file | |
from sanic import Sanic |
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
# models | |
from django import models | |
from django.utils.translation import ugettext_lazy as _ | |
class RowAttribute(models.Model): | |
"""Product/look row attribute model.""" | |
product = models.ForeignKey( | |
'ModelWithAttribute', verbose_name=_('Product'), | |
on_delete=models.CASCADE, null=True, |