示例#1
0
    
    print('done')
    # print(cleaned_google_results[0])
    print('#{} cleaned results after removing duplicates'.format(len(cleaned_google_results)))
    return cleaned_google_results

#################################################
# Flask Setup
#################################################

application = Flask(__name__)
# cors = CORS(app, resources={r"/api/*": {"origins": "*"}})
application.config['CELERY_BROKER_URL'] = 'redis://*****:*****@application.route("/fetch/", methods=["GET", "POST"]) 
def fetch():
    print('******************* AT Fetch')
    celery_add.delay(4, 5)
    """send variables to python"""
    if request.method == "POST":
        city = request.form["city"]
        city = city.lower().strip(' ')
        state = request.form["state"]
示例#2
0
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
import os
from flask_oauthlib.client import OAuth
from flask.ext.mail import Mail
from celery_config import make_celery
from twitterclient import TwitterClient
from config import basedir, ADMINS, MAIL_SERVER, MAIL_PORT, MAIL_USERNAME, MAIL_PASSWORD

app = Flask(__name__)
#app = Flask("somerandom")

app.config.from_object('config')
db = SQLAlchemy(app)
oauth = OAuth(app)
celery = make_celery(app)

# Set up email logging
if not app.debug:
    import logging
    from logging.handlers import SMTPHandler
    credentials = None
    if MAIL_USERNAME or MAIL_PASSWORD:
        credentials = (MAIL_USERNAME, MAIL_PASSWORD)
    mail_handler = SMTPHandler((MAIL_SERVER, MAIL_PORT), 'no-reply@' +
                                MAIL_SERVER, ADMINS, 'rando error', credentials)
    mail_handler.setLevel(logging.ERROR)
    app.logger.addHandler(mail_handler)

# Set up log file.
if not app.debug and os.environ.get('HEROKU') is None:
示例#3
0
import hmac
import os
from hashlib import sha1

from flask import Flask, request, Response
from flask.cli import load_dotenv
from tasks import pr_updated, pr_opened, pr_closed
from celery_config import make_celery

flask_app = Flask(__name__)
celery_app = make_celery(flask_app)


def log_info(message):
    flask_app.logger.info(message)


@flask_app.route('/')
def say_hello():
    return Response(
        "Hi. I'm the ChaBot. I spin up compute workers for codalab PRs!",
        status=200)


@flask_app.route('/pull_request', methods=('POST', ))
def pull_request():
    secret = os.environ.get('SPECIAL_SECRET')
    if not secret:
        log_info('Missing SPECIAL_SECRET environment variable')
        return Response(response='Server Error: missing environment variables',
                        status=500)
示例#4
0
from celery import group
from eventlet import Timeout
from flask import Flask
from requests.exceptions import RequestException

from celery_config import make_celery
from exceptions import BillingUpdateException
import subscription_services

flask_app = Flask(__name__)
flask_app.config.update(
    CELERY_BROKER_URL=os.environ["CELERY_BROKER"],
    CELERY_RESULT_BACKEND=os.environ["CELERY_BACKEND"],
)

celery = make_celery(flask_app)


@celery.task()
def post_data(url: str, payload: dict) -> dict:
    """
    Post Data
    """
    headers = {
        "Content-Type": "application/json",
        "Auth-key": os.environ["AUTH_KEY"],
    }
    res = requests.post(url, data=json.dumps(payload), headers=headers)
    return res.json()

示例#5
0
app = Flask(__name__)

app.config.update(CELERY_BROKER_URL='redis://*****:*****@celery.task(name="periodic_task")
def send_async_email():

    main()