Exemplo n.º 1
0
db.session.add_all([one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen,
                    fourteen, fifteen, sixteen, seventeen, eighteen, nineteen, twenty])
db.session.commit()
print('product levels created')


one = ProductView(9, 9, '2018-09-22 02:19:30')
two = ProductView(9, 7, '2018-09-27 02:47:43')
three = ProductView(9, 12, '2018-09-22 03:20:59')
four = ProductView(9, 10, '2018-09-29 03:07:11')
five = ProductView(9, 5, '2018-09-22 03:19:19')
six = ProductView(9, 8, '2018-09-21 15:57:50')
seven = ProductView(9, 6, '2018-09-22 02:12:54')
eight = ProductView(9, 1, '2018-09-22 03:03:36')

db.session.add_all([one, two, three, four, five, six, seven, eight])
db.session.commit()

print('product view data populated')


one = Users('Mukul', '*****@*****.**', 'mukul',
            '$5$rounds=535000$6PJhbzFlfJbcQbza$FbrPa3qqk1RJ5MSffRLO6LrQJXbgO8SudFuBpNf.wR7', '', '2018-07-23 14:09:14', '0', 'yes')
two = Users('Nur Mohsin', '*****@*****.**', 'mohsin', '$5$rounds=535000$EnLkwqfGWGcWklRL$q9PbYw/TVXSzs.QpgUouZ3.6BzaPG2eLHkTyv.Qx80D', '123456789022', '2018-07-21 06:47:57', '1', 'yes')
three = Users('Nur Mohsin', '*****@*****.**', 'khan', '$5$rounds=535000$wLKTQexvPQHueUsK$aFrFUXBHjrrAH61EFiYgj8cZECaaz8y6S5XS/zkkHw9', '', '2018-09-07 09:02:35', '0', 'yes')
four = Users('Robin', '*****@*****.**', 'robin', '$5$rounds=535000$uiZc/VCwwa3XCTTe$Ec.JOjy4GkjpAXHtAvGt6pSc6KszajHgcyZy8v6Ivk1', '', '2018-07-26 12:36:57', '0', 'yes')
five = Users('Sujon', '*****@*****.**', 'sujons', '$5$rounds=535000$aGykDT1yrocgTaDt$p2dDAMDz9g3N6o/Jj7QJY9B6NnMlUot.DCq/LOsCS13', '89345793753', '2018-09-08 13:58:36', '0', 'yes')

db.session.add_all([one, two, three, four, five])
db.session.commit()
print( ' Users created')
Exemplo n.º 2
0
from ..flask_util import jsonify_response
from .bucket import ip_rate_limit, token_rate_limit
from core.exceptions import UsernameAlreadyExists, ForbiddenArgument, LoginFailed, EmailAlreadyRegistered
from core.models import Users, Blogs
from core.cachemanager import CacheGenerator
from core.types_ import JsonStatus

__version__ = "0.1.0"

api = Blueprint("api",
                __name__,
                static_folder="../../static/",
                template_folder="../../templates/",
                url_prefix="/api")

users = Users()
blogs = Blogs()
CacheGenerator().generate_cache()


# AUTHENTICATION
def require_token(fn):
    """
    FYI: adds another argument to the function: the current token
    :raise: HTTP 403 if the token is not valid
    """
    @wraps(fn)
    def inner(*args, **kwargs):
        token = request.headers.get("Authorization")
        user_id = users.verify_token(token)
        if not token or not user_id: