def create_app(): app = Flask(__name__) app.config['SECRET_KEY'] = environ.get('SECRET_KEY') app.config['SQLALCHEMY_DATABASE_URI'] = environ.get( 'SQLALCHEMY_DATABASE_URI') app.config.update(CELERY_BROKER_URL=environ.get('REDIS_SERVER_URL'), CELERY_RESULT_BACKEND=environ.get('REDIS_SERVER_URL')) celery = make_celery(app) cache.init_app(app) db.init_app(app) from models.people_model import Person db.create_all(app=app) from views.home import home_bp app.register_blueprint(home_bp) from views.admin import admin admin.init_app(app) return app
def create_app(): app = Flask(__name__) app.config.from_pyfile('config.py') app.config.update( CELERY_BROKER_URL='redis://localhost:6379', CELERY_RESULT_BACKEND='redis://localhost:6379' ) celery = make_celery(app) api = Api(app) api.add_resource(Predict, '/predict') return app
def set_config(app): app.config['SECRET_KEY'] = 'secret!' password = os.environ['POSTGRES_PWD'] app.config.update( # Broker settings CELERY_BROKER_URL='amqp://localhost//', # Using the database to store task state and results CELERY_RESULT_BACKEND='db+postgresql://postgres:{}@localhost/user_data' .format(password)) socketio = SocketIO(app, engineio_logger=True, ping_timeout=120, message_queue='amqp://') celery = make_celery(app) return (socketio, celery)
import os from celery import Celery from flask import Flask from flask_celery import make_celery app = Flask(__name__) app.config['CELERY_BROKER_URL'] = os.environ.get('CELERY_BROKER_URL') app.config['CELERY_RESULT_BACKEND'] = os.environ.get('CELERY_RESULT_BACKEND') celery = make_celery(app) @app.route('/') def hello_world(): return 'hello world' @app.route('/process/<string>') def process(string): reverse.delay(string) return 'I sent an async request!' @celery.task(name='celery_example.reverse') def reverse(string): return string[::-1] if __name__ == "__main__": app.run(host="0.0.0.0", debug=True)
skill_table = dynamodb.Table('Skills') constraints_table = dynamodb.Table('Constraints') jobs_table = dynamodb.Table('Jobs') jobids_table = dynamodb.Table('JobIds') analysis_table = dynamodb.Table('Analysis') MAX_PAGES_PER_QUERY = 7 flask_app = Flask(__name__) CORS(flask_app) flask_app.config.update( CELERY_BROKER_URL= 'redis://project2-2.7xt2wp.ng.0001.use2.cache.amazonaws.com:6379', CELERY_RESULT_BACKEND= 'redis://project2-2.7xt2wp.ng.0001.use2.cache.amazonaws.com:6379') celery = make_celery(flask_app) @flask_app.route('/') def hello(): # return 'Hello, World!' return render_template('index.html', name=None) @flask_app.route("/delete-skill/<skill>") def delete_skill(skill): global skills try: del skills[skill] except: pass
from flask import Flask, request from flask_restful import Resource, Api from flask_celery import make_celery import json, pymongo, uuid app = Flask(__name__) api = Api(app) # Celery config app.config.update( CELERY_BROKER_URL='redis://localhost:6379', CELERY_RESULT_BACKEND='redis://localhost:6379' ) celery = make_celery(app) mongo = pymongo.MongoClient() db = mongo.wellsfargo @celery.task() def create_or_update_resource(resource): db_obj = { "_id": resource['id'], "object": resource } db.resources.update({ "_id": resource['id']}, db_obj, upsert=True); class WellsFargoExercise(Resource): def post(self, resource_id=None): """ Handles both the creation and updating of a record. If no resource_id is specified we assume creation mode, and generate a string identifier for a new record using the uuid functionality in the stdlib.
dash_debug_mode = os.getenv("DASH_DEBUG_MODE") redis_server = os.getenv("REDIS_SERVER") server = Flask(__name__) app = dash.Dash(server=server) cache = Cache(app.server, config={ 'CACHE_TYPE': 'simple', }) cache_timeout = 14400 # configure Celery server.config['CELERY_BROKER_URL'] = 'redis://%s:6379/0' % redis_server server.config['CELERY_BACKEND'] = 'redis://%s:6379/0' % redis_server celery = make_celery(server) #configure redis redis = redis.Redis(host=redis_server, port=6379, db=0) # available options for x axis available_x_axis = [{ "value": "tekopora", "label": "Cant. de beneficiarios (Tekopora)" }, { "value": "almuerzo", "label": "Cant. de escuelas priorizadas (Almuerzo Escolar)" }, { "value": "fundacion", "label":