Пример #1
0
from flask_jwt_extended import (create_access_token, create_refresh_token,
                                jwt_required, jwt_refresh_token_required,
                                get_jwt_identity, get_raw_jwt)

from run import api

parser = reqparse.RequestParser()
parser.add_argument('username',
                    help='This field cannot be blank',
                    required=True)
parser.add_argument('password',
                    help='This field cannot be blank',
                    required=True)

param = api.model('User registration', {
    'username': fields.String('username'),
    'password': fields.String('password')
})


class UserRegistration(Resource):
    @api.expect(param)
    def post(self):
        data = parser.parse_args()
        if UserModel.find_by_username(data['username']):
            return {
                'message': 'User {} already exists'.format(data['username'])
            }

        new_user = UserModel(username=data['username'],
                             password=UserModel.generate_hash(
                                 data['password']))
Пример #2
0
from run import api, fields

date_api_response = api.model(
    'date_api_response',
    {'name': fields.String(description='The name', required=True)})
Пример #3
0
from flask_restplus import fields
from run import api
from common.models import meta

cluster_base = api.model(
    'cluster', {
        'cluster_name': fields.String(description="Cluster Name"),
        'cluster_id': fields.String(description="Cluster Id"),
    })
Пример #4
0
from run import api, fields

add_date_api_request = api.model('add_date_api_request', {
    'name': fields.String(description='The name', required=True)
})
Пример #5
0
from flask_restplus import fields
from run import api
from common.models import meta

user_base = api.model(
    'signup', {
        'email': fields.String(description="Email ID"),
        'username': fields.String(description="First Name"),
        'firstname': fields.String(description="Last Name"),
        'password': fields.String(description="Password")
    })

user_request = api.inherit(
    'user base', user_base,
    {'confirm_password': fields.String(description="Confirm password")})

user = api.inherit(
    'user', user_base, {
        'is_active':
        fields.Boolean(default=False, description="Account Activated or Not"),
        'meta':
        fields.Nested(meta)
    })
Пример #6
0
from run import api, fields

add_user_api_request = api.model('add_user_api_request', {
    'name': fields.String(description='The user name', required=True),
    'email': fields.String(description='The user email', required=True)
})
from run import api, fields

user_api_response = api.model(
    'user_api_response', {
        'name': fields.String(description='The user name', required=True),
        'email': fields.String(description='The user email', required=True)
    })

user_list_api_response = api.model(
    'user_list_api_response',
    {'items': fields.List(fields.Nested(user_api_response))})
Пример #8
0
from datetime import datetime

from run import api, fields
from logic.speech2text_google import GoogleSpeechToText

response_model = api.model(
    'process_audio_response', {
        'processed_date':
        fields.String(description='Date the file was processed',
                      required=True),
        'file_name':
        fields.String(description='Name of file', required=True),
        'text':
        fields.String(description='Predicted text', required=True)
    })


class ProcessApudioResponse:
    def __init__(self, file_name, full_path):
        self.file_name = file_name
        self.full_path = full_path

        now = datetime.now()
        formatted_now = now.strftime("%A, %d %B, %Y at %X")
        self.processed_date = formatted_now

        self.text = ''

    def set_text(self, text):
        self.text = text
from run import api, fields

get_direcotry_response = api.model(
    'get_direcotry_response',
    {'href': fields.String(description='The directory href', required=True)})

get_direcotries_response = api.model(
    'get_direcotries_response',
    {'directories': fields.List(fields.Nested(get_direcotry_response))})
Пример #10
0
from flask_restplus import fields, reqparse
from run import api
from utils.date_utils import get_current_time

meta = api.model(
    'meta', {
        'is_deleted': fields.Boolean(default=False),
        'created_on': fields.DateTime(default=get_current_time()),
        'updated_on': fields.DateTime(default=get_current_time()),
        'created_by': fields.String(default='user'),
        'updated_by': fields.String(default='user')
    })

auth_parser = reqparse.RequestParser()
auth_parser.add_argument('Authorization', location='headers')