Example #1
0
def zip_est_income(household_size, zip):
	client = Client('e6e56d2e-b91e-4dc2-aac7-ec6028c378e2')

	# make sure our API key works
	client.ping().raise_for_status()	

	zipcode = client.get('income', zip)

	return zipcode['median']
Example #2
0
 def connect(self):
     client = Client(self.USR_KEY)
     client.ping().raise_for_status()
     return client
Example #3
0
#!/usr/bin/env python
from flask import Flask, redirect, url_for, render_template, jsonify
from porc import Client
from humanize import intword
from secrets import ORCHESTRATE_KEY
import random
app = Flask(__name__)
app.config["SERVER_NAME"] = "chopmotto.ml"
orche = Client(ORCHESTRATE_KEY, "https://api.aws-eu-west-1.orchestrate.io/")
orche.ping().raise_for_status()

tops = [""]
bots = [""]

with open("top.txt") as f:
    for line in f:
        if len(line.strip()) > 0:
            tops.append(line.strip())
print("%i tops loaded" % (len(tops)-1))

with open("bottom.txt") as f:
    for line in f:
        if len(line.strip()) > 0:
            if not line.strip().endswith("."):
                line = line.strip() + "."
            bots.append(line)
print("%i bottoms loaded" % (len(bots)-1))

@app.route("/api/<int:t>/<int:b>")
@app.route("/api/r/<int:b>")
@app.route("/api/<int:t>/r")
Example #4
0
import datetime
import embedly
import hashlib
import json
import nltk
import os
import requests
import uuid

# embedly
embedly_client = embedly.Embedly(os.environ['EMBEDLY_API_KEY'])

# orchestrate.io - data storage pluse search
client = Client(os.environ['ORCHESTRATE_API_KEY'])

client.ping().raise_for_status()

app = Flask(__name__)

def alchemy_call(service, params):
    ALCHEMY_URL = "http://access.alchemyapi.com/calls/url/"

    params['outputMode'] = 'json'
    params['apikey'] = os.environ['ALCHEMY_API_KEY']
    r = requests.get(ALCHEMY_URL + service, params=params)
    app.logger.debug('json: %s' % r.text)
    return json.loads(r.text)

def alchemy_flow(url):
    #extract category
    response = alchemy_call('URLGetCategory', {'url':url} )
Example #5
0
 def connect(self):
     client = Client(self.USR_KEY)
     client.ping().raise_for_status()
     return client
# Using .netrc keeps keys and other private data out of repositories.  Read up on .netrc for the details
# Get authentication secrets
secrets = netrc.netrc()

# Set the right datacenter for the Orchestrate data
orcHost = 'api.ctl-uc1-a.orchestrate.io'
orcURI = 'https://' + orcHost + '/v0'
# Set Orchestrate Credentials
orcUser, orcAcct, orcKey = secrets.authenticators(orcHost)

if DEBUG == 1:
    sys.stdout.write("Connecting to Orchestrate with key = " + orcKey + "\n")

# Connect to Orchestrate and validate key/connection
oClient = Client(orcKey, orcURI)
oClient.ping().raise_for_status()
# Set the mongo endpoint.
mongoEndpoint = '192.168.0.1'
mongoPort = '27017'
mongoURI = "mongodb://" + mongoEndpoint + ":" + mongoPort

# Set Mongo Credentials
mongoUser, mongoAcct, mongoBasePass = secrets.authenticators(mongoEndpoint)
mongoPass = mongoBasePass.decode('base64').rstrip('\n')

if DEBUG == 1:
    sys.stdout.write("Connecting to " + mongoURI + " with user: "******"\n")
client = MongoClient(mongoURI)

# Specify the database to use