示例#1
0
def js():
    bottle.response.content_type = 'application/javascript'
    
    lp = bottle.urljoin(bottle.request.url, bottle.url('/lp'))
    ct = bottle.urljoin(bottle.request.url, bottle.url('/ct'))
    
    return static.trackingjs % {'lp':lp, 'ct':ct}
示例#2
0
文件: controller.py 项目: kenna/trakr
def js():
    bottle.response.content_type = 'application/javascript'

    lp = bottle.urljoin(bottle.request.url, bottle.url('/lp'))
    ct = bottle.urljoin(bottle.request.url, bottle.url('/ct'))

    return static.trackingjs % {'lp': lp, 'ct': ct}
def get_all():
    """
        redirects the call to the agent configuration service
        on /v1/agents/all
    """     
    location = urljoin(AGENT_CONFIG_SERVER, '/v1/agents/all')
    raise HTTPResponse("", status=302, Location=location)
示例#4
0
def get_account(name):
    """
        redirects the call to the agent configuration service
        on /v1/agents/<name>/copnfig for the given name

    return map_and_redirect('/v1/agents/%s/', name)
    """
    #bidders_list = bidders.keys()
    #name = bidders_list[0]
    result = {
        'resultCode'        :   1,
        'resultDescription' :   'down'
    }


    account_name = ""
    proxy_support = urllib2.ProxyHandler({})
    opener = urllib2.build_opener(proxy_support)
    location = urljoin(
        AGENT_CONFIG_SERVER,
        '/v1/agents/%s/config' % bidders[name]['agent_conf_name'])
    logger.info('bringing up bidder config from: %s' % location)
    res = opener.open(location)
    try :
        data = res.read()
        logger.info('get_account :: config file: %s' % data)
        conf_json = json.loads(data)
        account_name = conf_json["account"][0]
    except :
        result['resultCode'] = 6
        result['resultDescription'] = 'unable to get config file with unexpected error'
        raise HTTPResponse(body=json.dumps(result), status=500,Content_Type='application/json')

    raise HTTPResponse(account_name, status=200, Content_Type='text/plain')
示例#5
0
 def get_url(routename, **kwargs):
     '''
     customized get_url to allow additional prefix args
     '''
     redirect = kwargs.pop('redirect', False)
     scriptname = bottle.request.environ.get('SCRIPT_NAME',
                                             '').strip('/') + '/'
     location = app.router.build(routename, **kwargs).lstrip('/')
     url = bottle.urljoin(bottle.urljoin('/', scriptname), location)
     if prefix and not redirect:
         url = prefix + '?' + bottle.urlencode({'q': url})
     append = '?'
     if '?' in url:
         append = '&'
     url += '{}_={}'.format(append, time.time())
     return url
示例#6
0
def get_all():
    """
        redirects the call to the agent configuration service
        on /v1/agents/all
    """     
    location = urljoin(AGENT_CONFIG_SERVER, '/v1/agents/all')
    raise HTTPResponse("", status=302, Location=location)
示例#7
0
文件: auth.py 项目: JFF-Bohdan/reqlog
    def get_redirect_response_object(url, code=None):
        if not code:
            code = 303 if bottle.request.get(
                "SERVER_PROTOCOL") == "HTTP/1.1" else 302

        res = bottle.response.copy(cls=HTTPResponse)
        res.status = code
        res.body = ""
        res.set_header("Location", bottle.urljoin(bottle.request.url, url))

        return res
def test(key,secret) :
    method = bottle.request.method
    url = bottle.urljoin(bottle.request.url,'/ajax')

    params = {
        'oauth_version': "1.0",
        'oauth_nonce': oauth2.generate_nonce(),
        'oauth_timestamp': oauth2.generate_timestamp(),
        'oauth_consumer_key':key
    }
    consumer = oauth2.Consumer(key=key,secret=secret)

    req = oauth2.Request(method=method, url=url, parameters=params)
    signature_method = oauth2.SignatureMethod_HMAC_SHA1()
    req.sign_request(signature_method, consumer, None)
    bottle.redirect(req.to_url())
示例#9
0
def test(key, secret):
    method = bottle.request.method
    url = bottle.urljoin(bottle.request.url, '/ajax')

    params = {
        'oauth_version': "1.0",
        'oauth_nonce': oauth2.generate_nonce(),
        'oauth_timestamp': oauth2.generate_timestamp(),
        'oauth_consumer_key': key
    }
    consumer = oauth2.Consumer(key=key, secret=secret)

    req = oauth2.Request(method=method, url=url, parameters=params)
    signature_method = oauth2.SignatureMethod_HMAC_SHA1()
    req.sign_request(signature_method, consumer, None)
    bottle.redirect(req.to_url())
示例#10
0
def get_config(name):
    """
        redirects the call to the agent configuration service
        on /v1/agents/<name>/config for the given name
    
    return map_and_redirect('/v1/agents/%s/config', name)
    """
    proxy_support = urllib2.ProxyHandler({})
    opener = urllib2.build_opener(proxy_support)
    location = urljoin(
        AGENT_CONFIG_SERVER,
        '/v1/agents/%s/config' % bidders[name]['agent_conf_name'])
    logger.info('bringing up bidder config from: %s' % location)
    res = opener.open(location)
    data = res.read()
    raise HTTPResponse(data, status=200, Content_Type='application/json')
示例#11
0
def map_and_redirect(uri, name):
    """
        maps the name, sets the uri and raises a redirection
        otherwise returns the json result code
    """
    try :
        # try to map the name to the internal config name     
        location = urljoin(
            AGENT_CONFIG_SERVER, 
            uri % bidders[name]['agent_conf_name'])
    except :
        return  {
                'resultCode'        :    1,
                'resultDescription' :   'unable to map %s' % name
                }
    raise HTTPResponse("", status=302, Location=location)
示例#12
0
def map_and_redirect(uri, name):
    """
        maps the name, sets the uri and raises a redirection
        otherwise returns the json result code
    """
    try :
        # try to map the name to the internal config name     
        location = urljoin(
            AGENT_CONFIG_SERVER, 
            uri % bidders[name]['agent_conf_name'])
    except :
        return  {
                'resultCode'        :    1,
                'resultDescription' :   'unable to map %s' % name
                }
        raise HTTPResponse(body=json.dumps(result), status=404, 
                Content_Type='application/json')
    raise HTTPResponse("", status=302, Location=location)