#!/usr/bin/env python # -*- coding: utf-8 -*- from flask import current_app as app from flask_restful import Resource, reqparse, abort from urllib.parse import urlparse from models import User, Chat, Bot #import tasks from celery_app import make_celery tasks_app = make_celery() class UserApi(Resource): def username_validator(self, value): """ Check if username is unique """ print(dir(User)) if User.exists(value): raise ValueError('username should be unique') else: return value def delete_user_validator(self, value): if User.exists(value): return value else: abort(400, username='******'t exist')
recognizer = AWSComprehendEntityRecognizer(app.config["AWS_S3_BUCKET"]) classifier = AwsComprehendClassifier( app.config["AWS_S3_BUCKET"], app.config["AWS_COMPREHEND_ROLE_ARN"], app.config["AWS_COMPREHEND_CLASSIFIER_ARN"], ) return { "Storage": storage, "Extractor": extractor, "Recognizer": recognizer, "Classifier": classifier, } celery = make_celery(app) @celery.task() def task_get_lease_thumbnail(lease_id, file_path): get_lease_thumbnail = GetLeaseThumbnail(init_infrastucture()["Storage"]) get_lease_thumbnail.execute( Request({ "lease_id": lease_id, "lease_file_path": file_path })) @celery.task() def task_extract_paragraphs(lease_id, file_path):
import os from flask import Flask from flask.ext.mail import Mail from flask.ext.sqlalchemy import SQLAlchemy from celery_app import make_celery from config import TEMPLATE_DIR, STATIC_DIR config_obj = os.environ.get("DIAG_CONFIG_MODULE", "config.test") app = Flask(__name__, template_folder=TEMPLATE_DIR, static_folder=STATIC_DIR) app.config.from_object(config_obj) db = SQLAlchemy(app) celery = make_celery(app) mail = Mail(app) # register urls from urls import * register_api_urls(app) register_base_urls(app) @app.route('/') def index(): return 'Hello World! from the index'