Esempio n. 1
0
File: app.py Progetto: lzvdijk/kathe
    'virustotal': 'https://www.virustotal.com/#/file/'
}

# XXX testing
# import json
# import math
# import redis
# REDISDB = 14
# rdb = redis.StrictRedis(host='localhost', db=REDISDB, decode_responses=True)

# app = application = Bottle(catchall=False)
# app.DEBUG=True
# app.debug=True
# decode responses is important here

plugin = redis.RedisPlugin(host='localhost', db=REDISDB, decode_responses=True)
install(plugin)


def roundrobin(*iterables):
    # Recipe credited to George Sakkis
    num_active = len(iterables)
    nexts = cycle(iter(it).__next__ for it in iterables)
    while num_active:
        try:
            for next in nexts:
                yield next()
        except StopIteration:
            # Remove the iterator we just exhausted from the cycle.
            num_active -= 1
            nexts = cycle(islice(nexts, num_active))
Esempio n. 2
0
File: app.py Progetto: sergray/kathe
DATA_SOURCES = defaults.DATA_SOURCES
KATHE_HOST = defaults.KATHE_HOST
KATHE_PORT = defaults.KATHE_PORT
REDIS_HOST = defaults.REDIS_HOST
REDIS_PASS = defaults.REDIS_PASS
SORTED_SET_LIMIT = defaults.SORTED_SET_LIMIT

try:
    REDIS_DB = sys.argv[1]
except IndexError:
    REDIS_DB = defaults.REDIS_DB

logging.info('Kathe frontend started using database #{}'.format(REDIS_DB))

plugin = redis.RedisPlugin(host=REDIS_HOST,
                           db=REDIS_DB,
                           password=REDIS_PASS,
                           decode_responses=True)
install(plugin)

base_path = os.path.abspath(os.path.dirname(__file__))

# ensure that bottle can use templates from the 'templates' folder
template_path = os.path.join(base_path, 'templates')
TEMPLATE_PATH.insert(0, template_path)


def aphash_color(gid):
    # AP hash function by Arash Partow
    s = str(gid)
    hash = 0xAAAAAAAA
    i = 0
# from bottle.ext import redis as redis_plugin
# import services.user_services as userService

#  app instance
defaultApp = default_app()
timelineApp = Bottle()

# Mount app
defaultApp.mount("/timeline", timelineApp)

# set up DB connection--------------------------------------------
connTimeline = sqlite3.connect('Project2-timeline.db')

# redis plugin
redis_plugin = bottle_redis.RedisPlugin()
timelineApp.install(redis_plugin)


# helper function for Divya
def dict_factory(cursor, row):
    d = {}
    for idx, col in enumerate(cursor.description):
        d[col[0]] = row[idx]
    return d


connTimeline.row_factory = dict_factory
cTimeline = connTimeline.cursor()

# Timelines service:
Esempio n. 4
0
File: app.py Progetto: ludel/ORQ-api
import tmdbsimple

from bottle import Bottle, response
from models.user import User
from views.movie import movie_app
from views.people import people_app
from views.recommendation import recommendation_app
from views.score import score_app
from views.session import session_app

DEBUG = os.environ.get('DEBUG', False)
tmdbsimple.API_KEY = os.environ['API_TOKEN']

main_app = Bottle()

redis_plugin = bottle_redis.RedisPlugin(host='localhost')

people_app.install(redis_plugin)
movie_app.install(redis_plugin)
score_app.install(redis_plugin)

main_app.merge(people_app)
main_app.merge(movie_app)
main_app.merge(score_app)
main_app.merge(recommendation_app)
main_app.merge(session_app)


@main_app.hook('after_request')
def enable_cors():
    response.headers[