sys.path.append('lib/') from instance import Service config = ConfigObj('config.ini') # define flask vars in caps DEBUG = True app = Flask(__name__) app.config.from_object(__name__) server = Server(uri=config['database']['url']) db = server[config['database']['name']] Service.set_db(db) if not db: raise RuntimeError('Database ' + config['database']['name'] + ' not found') def authenticate(): return Response( 'Unauthorized\n' 'You must provide proper credentials', 401, {'WWW-Authenticate': 'Basic realm="Login Required"'}) def check_auth(key,secret): return key == config['api']['authkey'] and secret == config['api']['secret'] def requires_auth(f): @wraps(f)